无法加载文件或程序集XXX或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配

Mar*_*sar 13 c# asp.net asp.net-mvc .net-assembly

在本地运行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)
Run Code Online (Sandbox Code Playgroud)

我刚刚System.Web.Optimization通过NuGet 添加了框架,它使用了WebGrease.

如果我检查引用,我的WebGrease版本是1.5.2.14234,高于抱怨没有找到的版本 - 1.5.1.25624.

在根网站配置中,我在运行时标记下面有以下内容:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

如果我检查服务器上bin文件夹中的WebGrease.dll,则WebGrease DLL的版本为1.5.2.14234.谁可能要求其他版本1.5.1.25624并且知道如何解决这个问题?

非常感谢!

Mar*_*sar 20

我们的结果是错误,因为服务器上的实际根网络配置有一个不正确的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>
Run Code Online (Sandbox Code Playgroud)

并不是:

<dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

因此错误发布的原因!