ASP.NET strange compilation error

I don’t know what’s wrong with my machine, but it’s a while that I’m getting the following strange error from ASP.NET (for all my applications).

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: The compiler failed with error code -1073741502.


Show Detailed Compiler Output:


C:WindowsSysWOW64inetsrv> "C:WindowsMicrosoft.NETFrameworkv4.0.30319csc.exe" /t:library /utf8output /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroot75855fbd1e953b27assemblydl32689d6b5f0791420_961fcc01wnvhtmlconvert.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystemv4.0_4.0.0.0__b77a5c561934e089System.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Drawingv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Drawing.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_32System.Webv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Web.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.Entityv4.0_4.0.0.0__b77a5c561934e089System.Web.Entity.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Webv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Web.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.IdentityModelv4.0_4.0.0.0__b77a5c561934e089System.IdentityModel.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroot75855fbd1e953b27assemblydl3d08c81cd4d77c01f_961fcc01AjaxControlToolkit.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Activationv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Activation.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.ApplicationServicesv4.0_4.0.0.0__31bf3856ad364e35System.Web.ApplicationServices.dll" ......AND SO ON.....

Facts:
  1. Killing worker process fixes the problem temporarily
  2. I even reinstalled my .NET framework! It didn’t work.
  3. Restarting IIS doesn’t help

What can cause this problem?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I removed Roslyn related packages by NuGet and it does work now.

Roslyn related packages:

  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform
  • Microsoft.Net.Compilers

P.S: My local IIS doesn’t have any problem with Roslyn but as I publish the project on the server (this is why I don’t think the server supports Roslyn), it shows the following error message:

Compilation Error

Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: The compiler failed with error code -532462766.

Show Detailed Compiler Output:

C:WindowsSysWOW64inetsrv>D:...wwwrootbinroslyncsc.exe /t:library /utf8output /nostdlib+ /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319mscorlib.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Runtimev4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Runtime.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3843389397359c03_e1abd201System.Web.WebPages.Deployment.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.Extensionsv4.0_4.0.0.0__31bf3856ad364e35System.Web.Extensions.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl32574b56eeed229e7_dfabd201Autofac.Integration.WebApi.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILMicrosoft.VisualStudio.Web.PageInspector.Loaderv4.0_1.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.Web.PageInspector.Loader.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl32da0bd13b2333a9c_e0abd201System.Net.Http.Formatting.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl399fd000ffe3c7c0e_e1abd201System.Web.WebPages.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3695a732a7a32e84e_e2abd201WebGrease.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Activitiesv4.0_4.0.0.0__31bf3856ad364e35System.Activities.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_32System.EnterpriseServicesv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.EnterpriseServices.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3ca091706f1f4ae28_78afd201Core.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3ce3c4f342b7b911a_e0abd201EntityFramework.SqlServer.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_32System.Datav4.0_4.0.0.0__b77a5c561934e089System.Data.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3c73494ac8f453228_78afd201CommonViewModels.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILMicrosoft.Web.Infrastructurev4.0_1.0.0.0__31bf3856ad364e35Microsoft.Web.Infrastructure.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319mscorlib.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.WorkflowServicesv4.0_4.0.0.0__31bf3856ad364e35System.WorkflowServices.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl33d13810845500f_e1abd201System.Web.Http.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl35cc83c7351b7f8fe_e0abd201System.Web.Http.WebHost.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3290d81d3fb074b29_78afd201Data.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Activationv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Activation.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl37a5d0293283dbf3a_e0abd201GridMvc.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3eb50e8c61900fa91_e0abd201System.Web.Razor.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3a7d6ceb34c5f9c2c_78afd201Web.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Xml.Linqv4.0_4.0.0.0__b77a5c561934e089System.Xml.Linq.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.WebPages.Deploymentv4.0_2.0.0.0__31bf3856ad364e35System.Web.WebPages.Deployment.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.DynamicDatav4.0_4.0.0.0__31bf3856ad364e35System.Web.DynamicData.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Xmlv4.0_4.0.0.0__b77a5c561934e089System.Xml.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystemv4.0_4.0.0.0__b77a5c561934e089System.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl33bd130ea7b432ba6_e0abd201System.Web.Optimization.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModelv4.0_4.0.0.0__b77a5c561934e089System.ServiceModel.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_32System.Webv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Web.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl38486430e674206e7_dfabd201Autofac.Integration.Mvc.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3c0d9cc0683811806_e1abd201System.Web.WebPages.Razor.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Configurationv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Configuration.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILMicrosoft.CSharpv4.0_4.0.0.0__b03f5f7f11d50a3aMicrosoft.CSharp.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl38835020a58c1c60e_e1abd201System.Web.Helpers.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl330c33f640d8a820_d154d201Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.IdentityModelv4.0_4.0.0.0__b77a5c561934e089System.IdentityModel.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Webv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Web.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl36ea00d7f2323228_78afd201Extensions.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3f8f1e397e9660a29_78afd201Services.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3ff57243fbb5e8b92_e0abd201System.Web.Mvc.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Runtime.Serializationv4.0_4.0.0.0__b77a5c561934e089System.Runtime.Serialization.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.WebPages.Deploymentv4.0_1.0.0.0__31bf3856ad364e35System.Web.WebPages.Deployment.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Drawingv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Drawing.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Data.DataSetExtensionsv4.0_4.0.0.0__b77a5c561934e089System.Data.DataSetExtensions.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Activitiesv4.0_4.0.0.0__31bf3856ad364e35System.ServiceModel.Activities.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3fd2c5d180ae74dd_e7acd201Autofac.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Corev4.0_4.0.0.0__b77a5c561934e089System.Core.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ComponentModel.DataAnnotationsv4.0_4.0.0.0__31bf3856ad364e35System.ComponentModel.DataAnnotations.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.ApplicationServicesv4.0_4.0.0.0__31bf3856ad364e35System.Web.ApplicationServices.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3a44c79bb74928fbb_e0abd201EntityFramework.dll" /R:"C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.Servicesv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Web.Services.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl3227cd18a6ab66d28_78afd201Domain.dll" /R:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06assemblydl38cbb60ec0788858_b3abd201Newtonsoft.Json.dll" /out:"C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06App_Code._bgj8eyw.dll" /debug- /optimize+ /warnaserror- /w:4 /nowarn:1659;1699;1701;612;618 /langversion:6 /nowarn:1659;1699;1701  "C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06App_Code._bgj8eyw.0.cs" "C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesroota47e39f5cc42bc06App_Code._bgj8eyw.1.cs"

How to uninstall the Roslyn packages.

In the Solution Explorer, by Right-Click on the web project, select Manage NuGet Packages....

Go to Installed tab then search the related Roslyn packages as mentioned at above.

Use Uninstall button to delete them.

Method 2

OK, after days struggling with this issue, I finally fixed it.

  • Not by clearing ASP.NET temp
  • Not by reinstalling the .NET framework!

Simple!

  • I changed the application pool identity from “Local system” to “ApplicationPoolIdentity”

Apparently there was a permission error with my local system that the C# compiler (csc.exe) could not access some resources and source codes.

In order to change your AppPool identity follow steps given here: http://learn.iis.net/page.aspx/624/application-pool-identities/

Method 3

What worked for me… It seems if you install (or a dependent package installs) Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package it makes some web.config transforms that allow you to use C#7.x features in ASP.NET Razor pages. Whilst I found these worked fine on my local machine they didn’t work on our server (even when the compiler was in the /bin/ folder).

The solution was to locate the element below and remove completely from web.config

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=&quot;Web&quot; /optionInfer+" />
    </compilers>
  </system.codedom>

Method 4

I got this kind of error too, but the problem was very different explained here. So in my case I got compiler error from temp file that I was using non existing namespace like:

using ImaginaryNamespaces;

I was sure that code “using ImaginaryNamespaces;” dosn’t exists in my solution so of course I doubt cache problem. Finally I figured out that the temporary file was some generated source file from configs. My Views/Web.Config had a line:
<add namespace="ImaginaryNamespaces"/>

After removing this it worked. So I recommend to make sure that there is not any data in configs that might be related to the compiler error.

Method 5

Delete C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files

Method 6

I just ran into this on .NET 4.6.1 and it ultimately had a simple solution – I removed (actually commented out) the section in the web.config and the web forms application came back to life. See what-exactly-does-system-codedom-compilers-do-in-web-config-in-mvc-5 for more info.

It worked for me.

Method 7

The answers provided are not the solution. The .NET 6# stuff is pretty different from what we used to. A lot has changed, from having to deal with portable libraries to Visual Studio 2015 installing an old compiler (it cost me four hours cracking my head).

The long story short: Stack Overflow question How do I use C# 6 with a Web Site project type?

You need to install the C# .NET compiler (now runs as a service bla bla bla).
and you need to run updates on NuGet to get the latest everything (before trying anything else).

The compiler must be installed on the project your solution runs from (so your website or your main project your application starts from (if you have multiple projects)).

Once you install that then sort out your web.config referencing any portable libraries, and delete both the bin and obj folder (to avoid works on my computer nightmare), It should just run. But be patient; what happens on your machine may vary as much as the answers above. Most of the answers above hide other problems. It may work for a while, then boom: compiler error. I had a few pages working, then some pages started failing because of some packages that have started using portable libraries.

Method 8

In IIS Manager, in the advanced settings of the Application Pool, make sure “Process Model → Load User Profile” is set to “True”. In my case it worked.

Method 9

I have crawled through a lot of blog posts including a few Stack Overflow pots, and I already had everything in place what these posts suggested (see below) when I got this error.

  1. My app pool is running under ApplicationPoolIdentity
  2. Load user Profile was set to True in Process Model section
  3. IIS AppPoolDefaultAppPool has full permissions on temp ASP.NET files folder

Finally I found some clues in the below mentioned blog post. It looks like there is heap contention with the same user account. So I changed the app pool identity to LocalSystem, for the app which is failing with this error – and my app started working fine.

See blog post C# compiler or Visual Basic .Net compilers fail with error code -1073741502 when generating assemblies for your ASP.net site.

Note: LocalSystem account will not have much permissions. In my case my application does not need any special permissions. So I was fine. If your application needs special permissions try configuring a custom account.

Method 10

If you get the error “An error occurred during the compilation of a resource required to service this request.
Compiler Error Message: The compiler failed with error code 255.”

Try to terminate the processes “VBCSCompiler.exe”. VBCSCompiler.exe can also be the problem if your application can not build due to the fact that some packages can not be transferred to the bin folder.

Method 11

I resolved this by deleting the contents of the bin and obj folders for the project, and the contents of the bin folder on the remote server, then redeploying.

Method 12

If you are still struggling to solve this issue, even after all options, then try to find application which is running and taking huge memory.

In my case it was an application which was having more than 100 instances running due to some error and that was taking at least 20 MB per application so around 2 GB.

After I killed the few applications and memory was released my site was back online.

Method 13

If you did deploy this application into your server, it’s possible that the *.config files in folder binroslyn were deleted.

Then review if exist the files like:

  • csc.exe.config
  • csi.exe.config
  • vbc.exe.config
  • VBCSCompiler.exe.config

These files can be variate depending on your project references.

Method 14

Cause: I have noticed that when I clean my project or clean one of the dependent projects and then hit refresh a few times on the page showing the site then it causes this error. It seems like it tries to load/run a broken/missing DLL project somehow.

Rename the project’s IIS directory to something different and with new name it loads fine (again providing project is built first OK then run otherwise it causes the same issue)

Method 15

I got the same error, came out of nowhere. After several hours of trying all the solutions mentioned here and on other forums, what worked for me was simple “Clean Solution” and “Rebuild” in VS2015.

Method 16

I had to kill multiple instances of MSBuild.exe hanging in process explorer.

Then the website runs OK.

Method 17

Updating Nuget packages fixed proglem for me.

Method 18

I had this error message and for me the solution was to install Dot Net Framework 4.6 ,While my project targeted 4.5.2

Method 19

The version of the Microsoft.Net.Compilers (3.0) used in my project was incompatible with the version of .NET installed on the server.

I downgraded the version to 2.1 and everything work fine now.

I guess it’s related to the different versions of .Net framework (guessing .NET Core) installed on the server.

Method 20

This kind of errors appears “strange” because they are related to the .NET Framework dynamic source code generation and compilation feature, and, in my opinion, the various errors generated are not reported with all the information needed to understand the real root cause. IIS will report only a generic failure like “Configuration Error” or “Compilation Error”, the command line of the dynamic compilation (with reference to temporary files created on-the-fly), and an error code.

Since the error is generic, by searching it on Internet (and in answers to this question), you’ll find several different solutions that solved the issue for other people, but will not necessarily solve the issue for your specific case.

For the specific error reported in this question “-1073741502”, the root cause appears to be a “DLL Initialization Failed” error during the compilation and from the following article it is likely to happen when the system is low on what is called Desktop Heap memory:
https://blogs.msdn.microsoft.com/friis/2012/09/19/c-compiler-or-visual-basic-net-compilers-fail-with-error-code-1073741502-when-generating-assemblies-for-your-asp-net-site/ .

The same blog post suggests to change the app pool account to give more “Desktop Heap memory” or to increase it by changing Windows registry. And the solution to change the app pool account is the one accepted for this answer: https://stackoverflow.com/a/6929129/1996150

Since the “dynamic compilation” of ASP.NET pages appears to be not mandatory if all the code is already compiled within Visual Studio, in many cases similar errors can be solved by manually removing the element “<system.codedom>” from web.config file or removing the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package (see https://stackoverflow.com/a/49903967/1996150).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x