asp.net - 在.NET 4.5 Azure部署中找不到编译器可执行文件csc.exe

标签 asp.net asp.net-mvc azure .net-4.5 windows-server-2012

我有一个曾经并且有效的网站:

  • ASP.NET 4
  • MVC 3
  • Entity Framework 4.3
  • 在 Azure Web 角色中运行(我注意到它是 osFamily="1",这很奇怪,因为我预计它是 2 - 但无论如何......)
  • Azure SDK 1.7

我已经升级了我的整个代码库,以便与大量新玩具保持同步。所以现在是:

  • ASP.NET 4.5
  • MVC 4( Razor 2)
  • Entity Framework 5
  • Azure 配置设置为 osFamily="3"
  • Azure SDK 1.8(存储客户端库经过精心升级到 2,而不是 1.7)

当我访问暂存站点时,出现蓝屏死机,提示无法找到编译器可执行文件 csc.exe。我的问题是为什么?

它在本地运行良好,在 Release模式下也运行良好。我进行远程连接,实例肯定运行的是 Windows Server 2012(因此是 .NET 4.5??我发现很难判断,因为 .NET 4.5 取代了 .NET 4 文件夹中的 .NET 4 程序集)。

根据响应 header ,它肯定运行 IIS 8,但有趣的是它声称 X-ASPNET-VERSION 是 4.xxxx。这对于 ASP.NET 4 网站来说正常吗?

更新:

我以 .NET 4 框架为目标,并将 osFamily 更改为 2,现在它可以工作了。所以我现在怀疑我有一个使用 .NET 3.5 或 2 的第 3 方程序集(事实上我确信我这样做),但是当目标 .NET 框架高于导入程序集中引用的框架时,肯定会使用更高版本的使用的框架??

osFamily="3"仅安装了 .NET 4 和 4.5,所以我想这就是错误的原因,但我对目标的看法是否正确?我想使用 osFamily="3"我可以在这里做什么?

堆栈跟踪

[InvalidOperationException: Compiler executable file csc.exe cannot be found.]
   System.CodeDom.Compiler.RedistVersionInfo.GetCompilerPath(IDictionary`2 provOptions, String compilerExecutable) +8675071
   Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames) +739
   Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources) +3293761
   Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources) +64
   HibernatingRhinos.Profiler.Appender.Util.GenerateAssembly.Compile(String fileName, String[] sources, IEnumerable`1 assembliesToReference) +1252
   HibernatingRhinos.Profiler.Appender.Util.GenerateAssembly.CompileAssembly(IEnumerable`1 sourcesResources, IEnumerable`1 assembliesToReference, String assemblyName) +118
   HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.SetupDatabaseDefaultConnectionFactoryIfNeeded() +929
   HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.SetupEntityFrameworkIntegration() +80
   HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize(EntityFrameworkAppenderConfiguration configuration) +47
   HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize() +73
   Web4.MvcApplication.Application_Start() +17

[HttpException (0x80004005): Compiler executable file csc.exe cannot be found.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Compiler executable file csc.exe cannot be found.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

最佳答案

我也有类似的问题。确保您的目标是正确的编译器。 我的目标是 v4.5(但应该有 v4.0,因为现在有 4.5 编译器)

在 web.config 中检查

<system.web>
 <compilation debug="true" defaultLanguage="c#" optimizeCompilations="true" targetFramework="4.0">
</system.web>

关于asp.net - 在.NET 4.5 Azure部署中找不到编译器可执行文件csc.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13343315/

相关文章:

ASP.NET MVC : Routing hierarchy URL

asp.net-mvc - 在控制台应用程序中创建 ASP.NET MVC 样式 View ?

azure - 调试时的 Windows Azure 缓存 - 请求超时

azure - 如何获取存储在 Azure 资源管理器中的捕获的 VM 镜像的 URL?

azure - 如何将附加文件部署到azure?

asp.net - 如何以编程方式单击 ASP.NET 网页上的按钮?

c# - 通过 LoadControl(Type, object[]) 重载以编程方式加载用户控件时,子控件为空

asp.net-mvc - 使用基于路由值的 AuthAttribute 安全调整 MVC 站点地图提供程序节点

c# - 检测页面刷新 jQuery 或 C# ASP.Net

C# HttpWebRequest - 如何确定是否发生 HTTP 301?