C# 无法加载文件或程序集 XXX 或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19585729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly XXX or one of its dependencies. The located assembly's manifest definition does not match the assembly reference
提问by Mark Cassar
When running an Asp.Net MVC application locally, everything runs fine but when application is deployed on the server, I am getting this error.
在本地运行 Asp.Net MVC 应用程序时,一切正常,但是当应用程序部署在服务器上时,我收到此错误。
Could not load file or assembly 'WebGrease, Version=1.5.1.25624, 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)
I have just recently added the System.Web.Optimization
framework through NuGet which makes use of WebGrease.
我最近刚刚System.Web.Optimization
通过使用 WebGrease 的 NuGet添加了框架。
If I check references, my version of WebGrease is 1.5.2.14234 which is higher than the one complaining about not finding - 1.5.1.25624.
如果我检查参考文献,我的 WebGrease 版本是 1.5.2.14234,高于抱怨找不到的版本 - 1.5.1.25624。
Within the root web config, I have the following underneath the runtime tag:
在根 web 配置中,我在运行时标签下有以下内容:
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
If I check the WebGrease.dll within the bin folder on the server, the version of the WebGrease DLL is 1.5.2.14234. Who could be requiring the other version 1.5.1.25624 and any idea how this can be solved?
如果我检查服务器上 bin 文件夹中的 WebGrease.dll,WebGrease DLL 的版本是 1.5.2.14234。谁可能需要其他版本 1.5.1.25624 并且知道如何解决这个问题?
Thanks a lot!
非常感谢!
采纳答案by Mark Cassar
It was a mistake from our end whereby the actual root web config on the server had an incorrect dependentAssembly
tag which consisted of:
这是我们最后的一个错误,服务器上的实际根 Web 配置有一个不正确的dependentAssembly
标签,其中包括:
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
and not:
并不是:
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
hence why the error was being issued!
因此为什么会发出错误!
回答by Hassue Rana
i just deleted everything in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET\ its working ... if u r using framework 4 then try C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\
我刚刚删除了 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET\ 中的所有内容......如果你使用框架 4 然后尝试 C:\Windows\Microsoft.NET\Framework\v4。 0.30319\ASP.NET 临时文件\
回答by Sunny Sharma
I tried installing the latest version from Nuget:
我尝试从 Nuget 安装最新版本:
install-package WebGrease
ReBuild the application twice and the error went away.
重新构建应用程序两次,错误消失了。
hope it help somebody!
希望它可以帮助某人!
回答by LukeP
I had the same error come up with my project as well. It turns out that there were several "XYZ-Copy.dll"'s in my bin directory that was causing the problem. I deleted all XYZ-copy.dll files and it worked.
我的项目也出现了同样的错误。事实证明,我的 bin 目录中有几个“XYZ-Copy.dll”导致了这个问题。我删除了所有 XYZ-copy.dll 文件并且它起作用了。
回答by Kris1
This was resolved by
这已解决
1) running the Package Manager Console
1) 运行包管理器控制台
2) in Console, type: 'Install-Package Microsoft.AspNet.Web.Optimization'
2) 在控制台中,输入:'Install-Package Microsoft.AspNet.Web.Optimization'
Which resolved all the incorrect dependencies and Successfully added Microsoft.AspNet.Web.Optimizationto the Project
解决了所有不正确的依赖项并成功地将Microsoft.AspNet.Web.Optimization添加到项目中