无法加载文件或程序集Microsoft.CodeAnalysis [英] Could not load file or assembly Microsoft.CodeAnalysis

查看:1662
本文介绍了无法加载文件或程序集Microsoft.CodeAnalysis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要托管的Web项目,但是当服务器尝试对其进行编译时,出现以下错误:

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

未处理的异常:System.IO.FileLoadException:无法加载文件 或程序集"Microsoft.CodeAnalysis,版本= 1.1.0.0,文化=中性, PublicKeyToken = 31bf3856ad364e35'或其中之一 依赖关系.找到的程序集的清单定义不 匹配程序集参考. (来自HRESULT的异常:0x80131040) ---> System.IO.FileLoadException:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 1.0.0.0,区域性=中性, PublicKeyToken = 31bf3856ad364e35'或其中之一 依赖关系.找到的程序集的清单定义不 匹配程序集参考. (来自HRESULT的异常:0x80131040)
---内部异常堆栈跟踪的结尾---在Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String [] args)

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.1.0.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) ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.0.0.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)
--- End of inner exception stack trace --- at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)

因此,该服务器具有比我的项目更旧的CodeAnalysis版本.因此,让我们尝试绑定重定向!

So the server has an older version of CodeAnalysis than my project. So lets try a binding redirect!

<dependentAssembly>
    <assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-9.9.9.9" newVersion="1.0.0.0" />
</dependentAssembly>

可悲的是,我仍然遇到相同的错误.我在做什么错了?

Sadly, I still get the same error. What am I doing wrong?

推荐答案

我自己弄清楚了这一点.对于任何阅读此书的人来说,问题在于Nuget包Microsoft.CodeDom.Providers.DotNetCompilerPlatform(其中也包含CodeAnalysis包)是错误的版本.我创建了一个新的Web项目,立即更新了有问题的Nuget程序包,问题已解决.

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.

这篇关于无法加载文件或程序集Microsoft.CodeAnalysis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆