【问题标题】:CSharpCodeProvider CompileAssemblyFromSource file not found under IIS在 IIS 下找不到 CSharpCodeProvider CompileAssemblyFromSource 文件
【发布时间】:2013-11-12 20:28:05
【问题描述】:

我们的网站根据配置编译从数据库加载的自定义 c# 代码。在我们的一台开发人员机器上,我们在编译时收到了一个未找到文件的错误。此代码在其他开发人员机器上运行良好。在开发人员机器上的 Visual Studio 开发服务器下运行时,它也可以正常工作。在这台特定机器上的 IIS 下运行时,它不起作用。以前,当网站安装在默认网站的子目录下时,它可以工作,但自从移动到 IIS 中的单独站点后,它就没有工作了。

CompilerResults results = compiler.CompileAssemblyFromSource(
                              compilerParameters, source);

if (results != null && results.Errors.HasErrors)
{
    StringBuilder stringBuilder = new StringBuilder();
    foreach (CompilerError error in results.Errors)
    {
        stringBuilder.AppendLine(error.ErrorText);
    }

    throw new StoreTechException(
        String.Format("Unable to generate KPI calculation assembly:{0}{1}",
            Environment.NewLine, stringBuilder.ToString()), 
        StoreTechExceptionTypes.Error);
}

return results;

产生的错误信息是:

CS2001: Source file 'C:\\Windows\\TEMP\\zyxl54ci.0.cs' could not be found 
CS2008: No inputs specified

由于它在 Visual Studio 开发服务器而不是 IIS 下工作,我们想知道这是否是权限问题。

【问题讨论】:

  • 什么版本的 Windows/IIS?您网站的池帐户在什么身份下运行?
  • @Kev Windows 7 专业版。 IIS 7.5。下次见到开发人员时,我需要等到星期二才能确定回答第二个问题。除了将应用程序池设置为 .NET 4.0 之外,我不知道应用程序池有什么不寻常的事情,所以它可能是默认值。
  • 我也有同样的错误信息。在我的情况下,应用程序池身份没有足够的权限。
  • @lippo 启用代码编译所需的具体权限是什么?
  • 我选择了一种简单的方法。我已将应用程序池用户添加到管理员组。但我认为用户只需要临时目录的写权限。

标签: c# asp.net iis dynamic compilation


【解决方案1】:

应用程序池标识需要临时目录(C:\Windows\TEMP)上的写入权限

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-26
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多