Reputation: 655
Other articles on here haven't been able to solve my issue. The following errors are being thrown when I run my ASP.NET MVC5 Web Project.
Anyone got an idea where I am going wrong?
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/{name}/Documents/git/Project/
LOG: Initial PrivatePath = C:\Users\{name}\Documents\git\Project\bin
Calling assembly : (Unknown)
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\{name}\Documents\git\Project\web.config
LOG: Using host configuration file: C:\Users\{name}\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/{name}/AppData/Local/Temp/Temporary ASP.NET Files/vs/b2d7334d/e3876cf7/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.DLL.
LOG: Attempting download of new URL file:///C:/Users/{name}/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/{name}/Documents/git/Project/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.
Upvotes: 46
Views: 72370
Reputation: 1
I had the same issue on visual studio 2019 where i cannot install / uninstall the Microsoft.CodeDom.Providers.DotNetCompilerPlatform nugget.
it was solve by moving my project directory to root because the accessing path was too long D:\Projets\2023**********\transfert\20231028DEV_2022_2023\DEV_2022_2023\ProcessAndWeb_VS********\PROJetDirectory => move to a shorter path as: D:\DEV__2022_2023\ProcessAndWeb_VS******************\PROJetDirectory
Upvotes: 0
Reputation: 686
see the right side , if there any version different , update that
Upvotes: 0
Reputation: 39
In Visual Studio 2022, Updating Microsoft.CodeDom.Providers.DotNetCompilerPlatform is solution for me.
Thanks https://stackoverflow.com/a/51037305/5337709
My Web.config looks like before "Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform" as:
<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=\"Web\" /optionInfer+" />
</compilers>
After update;
<compilation debug="true" targetFramework="4.7.2" />
Upvotes: 1
Reputation: 5279
You may get this error if
If this is the case, then the problem may be resolved by deleting the target folder you are publishing to and then publishing your application again.
A possible explanation WHY this happens may be in this answer: https://stackoverflow.com/a/57609105/2279059
Upvotes: 2
Reputation: 336
Just run this command in the Package Manager Console:
Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r
Upvotes: 7
Reputation: 667
This problem comes from your Nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
.
It is the wrong version. You can remove the Current Version then install again from Nuget.
Upvotes: 23
Reputation: 1252
Resolved by according to the response of Jeff Woods :
<PropertyGroup>
<OutputPath>bin\</OutputPath>
</PropertyGroup>
Upvotes: 0
Reputation: 420
It can also happen if your target folder is something other than "bin/". Roslyn by default looks for the "roslyn" folder in the "bin" folder, so if you are compiling, for example, to "bin/debug/", there may not be a roslyn folder there, and thus it can't find the provider.
You can fix this by reverting to a plain "bin/" target, or by ensuring that a full roslyn folder is copied across to the "bin/debug/" folder as a Post-Build event. Because a publish always pushes to the correct target folder despite the compilation target folder of your build machine, that's why it fails when you run locally, but works if you deploy it.
(Some people have the opposite problem, it working locally, but fails when deployed to IIS, because IIS doesn't have a copy of the CodeDom provider in its GAC, but that's a totally different issue.)
Upvotes: 4
Reputation: 656
We just had this error in one of our test environments. The problem was in the web.config file. The section had settings to reference the DotNetCompilerPlatform assembly, but had the wrong version number. We updated web.config to the proper version number and it fixed the error.
<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=\"Web\" /optionInfer+" />
</compilers>
Upvotes: 59