【问题标题】:Could not load file or assembly XXX or one of its dependencies. The located assembly's manifest definition does not match the assembly reference无法加载文件或程序集 XXX 或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配
【发布时间】:2013-10-25 09:13:08
【问题描述】:

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

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

如果我查看参考资料,我的 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 以及如何解决这个问题?

非常感谢!

【问题讨论】:

    标签: c# asp.net asp.net-mvc .net-assembly


    【解决方案1】:

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

    因此为什么会发出错误!

    【讨论】:

    • 这也是我的问题。在我这边,在发布期间,它在 web 配置转换上,因为服务器和我的 PC 的 dll 具有不同的版本(我将上面的代码放在 和 bindingRedirect newVersion 上)。我只是取消了预编译选项,因为旧的 dll 只存在于服务器上,以便继续发布。
    【解决方案2】:

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

    【讨论】:

    • 呸,我讨厌这样的东西。我向云备份服务添加了一个项目,它在我的 bin 目录中创建了一个重复的 .dll。感谢您提供正确方向的提示。
    • 乐于助人!这些小问题让我抓狂!
    【解决方案3】:

    我刚刚删除了 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET\ 中的所有内容 它的工作......如果你使用框架 4 然后尝试 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\

    【讨论】:

    • 感谢您的评论,但正如我之前的回答中所述,由于 web.config 文件中的错误已解决,如前所述。
    • 更一般的性质(与“WebGrease”无关)如果您的应用程序池在未启用 32 位的情况下启动,则可能会发生此错误,然后您将其更改为启用。这个答案解决了这个问题。
    【解决方案4】:

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

     install-package WebGrease
    

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

    希望对某人有所帮助!

    【讨论】:

      【解决方案5】:

      已解决

      1) 运行包管理器控制台

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

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

      【讨论】:

        猜你喜欢
        • 2017-11-24
        • 1970-01-01
        • 2014-01-21
        • 2019-12-04
        • 2021-10-15
        • 1970-01-01
        • 2013-08-24
        • 1970-01-01
        • 2015-10-30
        相关资源
        最近更新 更多