The csc.exe compiler executable was not found in .NET 4.5. Azure Deployment

I have a website that has been up and running:

  • ASP.NET 4
  • MVC 3
  • Entity Framework 4.3
  • Running in Azure web roles (I noticed that this is osFamily = "1", which is strange since I expected it to be 2 - but anyway ...)
  • Azure SDK 1.7

I updated my entire code base to keep abreast of many new toys. So now this is:

  • ASP.NET 4.5
  • MVC 4 (Razor 2)
  • Entity Framework 5
  • Azure configuration set to osFamily = "3"
  • Azure SDK 1.8 (with a client repository library carefully updated to version 2, not 1.7).

When I access the site at the creation stage, I get a yellow screen of death, saying the csc.exe compiler executable cannot be found . My question is why?

It works great in local mode and in Release mode. I retired and Windows Server 2012 definitely works on instances (why is .NET 4.5? It was hard for me to say, since .NET 4.5 replaces .NET 4 assemblies in .NET 4 folders).

According to the response headers, it definitely works with IIS 8, but it is interesting that X-ASPNET-VERSION is 4.xxxx. Is this normal for an ASP.NET 4 site?

UPDATE:

I aimed at the .NET 4 platform and changed osFamily to 2, and now it works. Therefore, I now suspect that I have a third-party assembly that uses .NET 3.5 or 2 (indeed, I'm sure I do), but , of course, when targeting the .NET platform it is higher than the reference ones in imported assemblies higher version of the frame used

osFamily = "3" only installed .NET 4 and 4.5, so I think this is the cause of the error, but am I wrong about targeting? I want to use osFamily = "3", what can I do here?

Stack trace

[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 
+8
asp.net-mvc azure windows-server-2012
source share
4 answers

Well, David Abbo pointed me in the right direction, and I began to carefully study the Entity Framework Profiler. There is a thread here.

Something in this build creation at runtime, and it would seem osfamily = "3" (Server 2012) would not allow this (it worked on osfamily = "2" (Server 2008 R2). I am not going to debug more than that because I do not want the profiler in my live environment anyway. Removing the EF Profiler made it work.

+1
source share

Yes, if you have Server 2012, you are definitely using Fx 4.5, not 4.0, as it is being updated.

To answer your question in bold, this ASP.NET application can only use one structure at a time. If you are working as a site 4.5, then all assemblies 2.0 / 3.5 should start in the same way as in frame 4.5.

Therefore, I suspect that these old builds are not the root of your problem.

Saying I can not explain the csc problem. This may help to include the exact error message you receive, as well as some stack traces.

+2
source share

I had a similar problem. Make sure you configure the correct compiler. I aimed at v4.5 (but there shoulders will be v4.0, since now there is 4.5 compiler)

In web.config check

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

I publish this in the hope that this will help someone. We dynamically compiled the code with version 2 of the framework, and on the .net 4 server we received an error message. It was just because we hardcoded the framework version:

 var provider = new CSharpCodeProvider(new Dictionary<String, String> { { "CompilerVersion", "v3.5" } }); 

Thus, it is just a matter of removing this - apparently, it compiles with any version of the framework at this time.

 var provider = new CSharpCodeProvider(); 

Thus, the error is only that the code should be compiled, but there is no compiler for the required version of the frame. Another option was to make sure .net 3.5 was installed.

0
source share

All Articles