IIS Compilation Error -2146232576 AspNetInitializationExceptionModule

后端 未结 9 719
执笔经年
执笔经年 2020-12-05 07:35

I have a fairly simple C# WebAPI2 project that runs locally but after publishing to IIS on a remote machine (Windows Server 2012 R2 Standard) the web page displays the follo

相关标签:
9条回答
  • 2020-12-05 07:35

    I upgraded the .NET framework to version 4.6 and it worked. The Roslyn packages are dependent on versions 4.5+, but it didn't work. So the upgrade made it work.

    0 讨论(0)
  • 2020-12-05 07:36

    Error:

    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 -2146232576.

    Solution:

    I faced with this problem after upgrade some NuGets and solved with below steps.

    Step 1: Remove these NuGet packages from NuGet Package Console

    PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    PM> Uninstall-package Microsoft.Net.Compilers
    

    Step 2: Add these system.codedom lines before closing </system.data> tag in 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>
                <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+"></compiler>
            </compilers>
        </system.codedom>
    

    PS: After a while, we removed <system.codedom> completely, for fixed other errors.

    0 讨论(0)
  • 2020-12-05 07:37

    I upgraded the NuGet package "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" from 2.0.0 to 2.0.1 and that resolve this issue for me

    0 讨论(0)
  • 2020-12-05 07:41

    For me, a similar issue was resolved by letting the other user of a server publish the app again. Everytime I published the app, it was depending on a temporary ASP.NET folder that did not exists for the other user. I hope this helps.

    0 讨论(0)
  • 2020-12-05 07:50

    for me helped just remove NuGet packages above:

    Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    

    Microsoft.Net.Compilers

    Recompile and then add them back.

    0 讨论(0)
  • 2020-12-05 07:56

    For me, it was because i tried to build a string for the Roles property of the attribute Authorize on my class.

    [Authorize(Roles = IdentityRoles.Administrator + "," + IdentityRoles.BaseData)]
    

    I had to build the different strings and just set one constant to Roles:

    [Authorize(Roles = IdentityRoles.AutorizationStrings.AdminBaseData)]
    

    where

    IdentityRoles.AutorizationStrings.AdminBaseData = "Administrator,Base data";
    

    Hope this helps anybody that tricks themself down this hole.

    0 讨论(0)
提交回复
热议问题