无法加载文件或程序集'Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Tei*_*ije 4 asp.net visual-studio asp.net-mvc-5

这里的其他文章无法解决我的问题。当我运行ASP.NET MVC5 Web项目时,将引发以下错误。

有人知道我要去哪里了吗?

Could not load file or assembly 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)



=== Pre-bind state information ===
LOG: DisplayName = Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Teije/Documents/git/Project2.2/HaarlemFestival-Web/
 LOG: Initial PrivatePath =         C:\Users\Teije\Documents\git\Project2.2\HaarlemFestival-Web\bin
Calling assembly : (Unknown)
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Teije\Documents\git\Project2.2\HaarlemFestival-Web\web.config
LOG: Using host configuration file: C:\Users\Teije\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference:     Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/Teije/AppData/Local/Temp/Temporary ASP.NET Files/vs/b2d7334d/e3876cf7/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.DLL.
LOG: Attempting download of new URL file:///C:/Users/Teije/AppData/Local/Temp/Temporary ASP.NET     Files/vs/b2d7334d/e3876cf7/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.DLL.
LOG: Attempting download of new URL file:///C:/Users/Teije/Documents/git/Project2.2/HaarlemFestival-    Web/bin/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Run Code Online (Sandbox Code Playgroud)

Mah*_*deh 14

这个问题来自你的 Nuget 包Microsoft.CodeDom.Providers.DotNetCompilerPlatform

这是错误的版本。您可以删除当前版本,然后从 Nuget 重新安装。


小智 6

我们只是在其中一个测试环境中遇到了此错误。问题出在web.config文件中。本节中的设置引用了DotNetCompilerPlatform程序集,但是版本号错误。我们将web.config更新为正确的版本号,并修复了该错误。

<compilers>
  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /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.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
Run Code Online (Sandbox Code Playgroud)

  • 在我安装 Nuget 包后,它确实更新了 Web.config,但没有更新嵌套在其下的配置 (web.base.config),因此当我构建项目时,它被覆盖了。要解决此问题,请在安装 Nuget 包时复制父 Web.config 文件的更改部分,然后替换嵌套配置文件中的相应部分。 (3认同)

Jar*_*ufi 5

只需在包管理器控制台中运行以下命令:

更新包 Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r