13

在本地运行 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)

我最近刚刚System.Web.Optimization通过使用 WebGrease 的 NuGet 添加了框架。

如果我检查参考,我的 WebGrease 版本是 1.5.2.14234,它高于抱怨找不到的版本 - 1.5.1.25624。

在根 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>

如果我检查服务器上 bin 文件夹中的 WebGrease.dll,WebGrease DLL 的版本是 1.5.2.14234。谁可能需要其他版本 1.5.1.25624 以及如何解决这个问题?

非常感谢!

4

5 回答 5

18

这是我们的一个错误,服务器上的实际根 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>

并不是:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>

因此为什么会发出错误!

于 2013-10-25T09:18:24.530 回答
4

我的项目也出现了同样的错误。事实证明,我的 bin 目录中有几个“XYZ-Copy.dll”导致了问题。我删除了所有 XYZ-copy.dll 文件,它工作正常。

于 2014-07-21T17:38:45.287 回答
2

我尝试从 Nuget 安装最新版本:

 install-package WebGrease

重新构建应用程序两次,错误就消失了。

希望对某人有所帮助!

于 2014-03-13T12:25:33.507 回答
2

我刚刚删除了 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET\ 中的所有内容...如果您使用框架 4,请尝试 C:\Windows\Microsoft.NET\Framework\v4。 0.30319\临时 ASP.NET 文件\

于 2014-01-28T10:17:43.227 回答
1

这被解决了

1) 运行包管理器控制台

2) 在控制台中,输入:'Install-Package Microsoft.AspNet.Web.Optimization'

解决了所有不正确的依赖项并成功将Microsoft.AspNet.Web.Optimization添加到项目中

于 2015-06-19T00:16:44.160 回答