Could not load file or assembly Microsoft.CodeAnalysis

前端 未结 6 1360
庸人自扰
庸人自扰 2021-01-01 08:50

I have a webproject I am trying to host, but when the server tries to compile it, I get the following error:

Unhandled Exception: System.IO.FileLoadE

相关标签:
6条回答
  • 2021-01-01 09:28

    Other possible fix (at least for Visual Studio 2015):

    Get the latest Visual Studio update.

    You can check for updates by going to Tools/Extensions and Updates/Updates

    Same as this Q/A: Visual Studio 2015: Quick Actions no longer working, error: Could not load file or assembly Microsoft.CodeAnalysis

    0 讨论(0)
  • 2021-01-01 09:29

    I resolved this issue but ensuring that the version numbers of the assemblies in my web.config were correct.

    Edit:

    I hit this problem as well and some may wonder how the Web.Config can become incorrect. In my case I am using Web.Config Transforms so the Web.Config file gets overwritten:

    Changing the version number in Web.Configs compiler (in the Web.Template.Config) to the number matches the NuGet version does solve the issue:

    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0
    
    0 讨论(0)
  • 2021-01-01 09:29

    If none of mentioned options work, please go for this answer. Basically, you are registering that Microsoft.CodeAnalysis.dll to GAC

    Could not load file or assembly 'Microsoft.CodeAnalysis, version= 1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc

    0 讨论(0)
  • 2021-01-01 09:30

    I have had this problem today while doing an Umbraco v7.13.0 upgrade, simply updating the following package has fixed my problem, this is apparently a common problem with things like Umbraco upgrades.

    Update-Package -Reinstall Microsoft.CodeAnalysis.CSharp
    
    0 讨论(0)
  • 2021-01-01 09:35

    I figured this out myself. To anyone reading this, the problem was that the Nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform (which also contains the CodeAnalysis package) was the wrong version. I created a new webproject, updated the offending Nuget package right away, and the problem was solved.

    0 讨论(0)
  • 2021-01-01 09:51

    Right click on your project >> Manage Nuget packages manager for solution >> Tap on Updates >> Update your 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform' >> and then run your project again.

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