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

Bri*_*per 8 asp.net asp.net-mvc azure .net-4.5 windows-server-2012

我有一个网站,和工作原理:

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

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

  • ASP.NET 4.5
  • MVC 4(剃刀2)
  • 实体框架5
  • Azure配置设置为osFamily ="3"
  • Azure SDK 1.8(存储客户端库精心升级到2而不是1.7)

当我在分期中访问该网站时,我得到一个黄色的死亡屏幕,说无法找到编译器可执行文件csc.exe.我的问题是为什么?

它在本地工作正常,在发布模式下也是如此.我转发了,实例肯定在运行Windows Server 2012(因此.NET 4.5?我已经看到它很难说,因为.NET 4.5替换了.NET 4文件夹中的.NET 4程序集).

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

更新:

我将.NET 4框架作为目标,并将osFamily更改为2,现在可以使用了.所以我现在怀疑我有一个使用.NET 3.5或2的第三方程序集(事实上我确定我这样做)但是当针对比导入程序集中引用的.NET框架更高的.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
Run Code Online (Sandbox Code Playgroud)

Bri*_*per 1

好吧,David Ebbo 为我指明了正确的方向,我开始仔细研究 Entity Framework Profiler。这里有一个关于它的线程。

关于它在运行时创建程序集的一些事情,似乎 osfamily="3" (Server 2012) 不允许这样做(它在 osfamily="2" (Server 2008 R2) 上工作)。不会再进行调试了,因为无论如何我都不希望在我的实时环境中使用探查器。删除 EF Profiler 即可正常工作。