c# - 无法加载文件或程序集“Microsoft.CodeDom.Providers.DotNetCompilerPlatform。 (来自 HRESULT : 0x80131040) 的异常

标签 c# model-view-controller

无法加载文件或程序集“Microsoft.CodeDom.Providers.DotNetCompilerPlatform,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。找到的程序集的 list 定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)

我为 WebApi 身份验证安装了以下 dll 文件

Microsoft.Owin
Microsoft.Owin.Host.SystemWeb
Microsoft.Owin.Security.OAuth
Microsoft.Owin.Security
Microsoft.AspNet.Identity.Owin

此错误只会发生在托管环境中。 它将在托管 [Which development machine] 和代码的本地机器上运行良好。

最佳答案

从您的托管网站的网络配置中删除此代码

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

这是我发布的网站的网络配置

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>


  <system.web>


    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="1048576000"/>


  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

关于c# - 无法加载文件或程序集“Microsoft.CodeDom.Providers.DotNetCompilerPlatform。 (来自 HRESULT : 0x80131040) 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53443038/

相关文章:

c# - DataGrid 列绑定(bind)到 List 的项目

c# - 是否可以有一个未知类型的数组?

c# - 如何通过调用带字符串参数的 WiX 自定义操作的 Installshield 创建自定义操作?

java - Intellij 无法编译项目。资源编译器错误

json - Emacs 中类似模型/ View 的编辑

mysql - 如何在 Ruby on Rails 中连接 MySQL 表?

model-view-controller - MVC : Where to trigger user registration emails

c# - 使用 JSON.net 序列化 Dictionary<int,object>?

c# - 如何遍历 configurationSection

mysql - 有没有办法从 Ruby-on-Rails 模型中获取数据库中的数据