IIS 编译错误 -2146232576 AspNetInitializationExceptionModule [英] IIS Compilation Error -2146232576 AspNetInitializationExceptionModule
问题描述
我有一个相当简单的 C# WebAPI2 项目,它在本地运行,但在远程机器(Windows Server 2012 R2 Standard)上发布到 IIS 后,网页显示以下内容(将 customErrors 设置为关闭"后):
<块引用>/"应用程序中的服务器错误.编译错误说明:编译所需资源时出错服务这个请求.请查看以下特定错误详细信息并适当修改您的源代码.编译器错误消息:编译器失败,错误代码为 -2146232576.
如果我获取 详细的编译器输出并在 IIS 服务器上运行它,我会得到一个智能屏幕错误消息说:
<块引用>此应用无法在您的 PC 上运行.要查找适用于您 PC 的版本,请咨询软件发行商.
我猜这与编译器版本有关,但自上次发布以来没有任何变化.
有什么想法吗?
错误:
<块引用>编译错误
描述:编译资源时出错需要为该请求提供服务.请查看以下具体错误详细信息并适当修改您的源代码.
编译器错误信息:编译器失败,错误代码-2146232576.
解决方案:
我在升级一些 NuGet 后遇到了这个问题,并通过以下步骤解决了.
第 1 步:从 NuGet 包控制台
PM>卸载包 Microsoft.CodeDom.Providers.DotNetCompilerPlatform下午>卸载包 Microsoft.Net.Compilers
第 2 步: 在 Web.config 中关闭
</system.data>
标记之前添加这些 system.codedom
行
<编译器><编译器语言=c#;cs;csharp";扩展名=.cs"type=Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,Microsoft.CodeDom.Providers.DotNetCompilerPlatform,版本=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"警告级别=4"compilerOptions="/langversion:6/nowarn:1659;1699;1701"></compiler><编译器语言=vb;vbs;visualbasic;vbscript";扩展名=.vb"type=Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,Microsoft.CodeDom.Providers.DotNetCompilerPlatform,版本=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"警告级别=4"compilerOptions="/langversion:14/nowarn:41008/define:_MYTYPE="Web"/optionInfer+"></compiler></编译器></system.codedom>
PS:一段时间后,我们完全删除了
,以修复其他错误.
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 following (after setting customErrors to "Off"):
Server Error in '/' Application. 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.
If I grab the detailed compiler output and run it on the IIS server, I get a smartscreen error message saying:
This app can't run on your PC. To find a version for your PC, check with the software publisher.
I'm guessing it's something to do with the compiler version but nothing has changed since it last published.
Any ideas?
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="Web" /optionInfer+"></compiler>
</compilers>
</system.codedom>
PS: After a while, we removed <system.codedom>
completely, for fixed other errors.
这篇关于IIS 编译错误 -2146232576 AspNetInitializationExceptionModule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!