【问题标题】:Comparing the assembly name resulted in the mismatch: Revision Number比较程序集名称导致不匹配:修订号
【发布时间】:2020-01-25 06:43:38
【问题描述】:

我正在开发 ASP.NET MVC4 应用程序,该应用程序在我的本地计算机上运行良好,但在应用程序服务器上无法运行并引发以下错误:

无法加载文件或程序集'System.Web.Mvc,版本=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 或其之一 依赖关系。定位程序集的清单定义不 匹配程序集引用。 (HRESULT 异常:0x80131040)

网络配置:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>

当我将 System.Web.Mvc 的版本更改为执行版本时,即 4.0.40804.0 我得到了几乎类似的错误:

<dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.40804.0" newVersion="4.0.40804.0" />
      </dependentAssembly>

LOG:此绑定在默认加载上下文中开始。日志:使用应用程序 配置文件:D:\mywebapp\web.config 日志:使用主机 配置文件: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config 日志: 使用来自的机器配置文件 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config。 日志:此时未将策略应用于参考(私人, 自定义、部分或基于位置的程序集绑定)。日志:尝试 下载新网址 file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/f56977f7/c98ce4c8/System.Web.Mvc.DLL。日志: 正在尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/f56977f7/c98ce4c8/System.Web.Mvc/System.Web.Mvc.DLL。日志: 正在尝试下载新 URL 文件:///D:/RHDHV_Websites/Graafgebiedinformatie/bin/System.Web.Mvc.DLL。 日志:使用应用程序配置文件:D:\mywebapp\web.config 日志: 使用主机配置文件: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config 日志: 使用来自的机器配置文件 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config。 日志:在应用程序配置文件中找到重定向:4.0.0.1 重定向到 4.0.40804.0。 LOG:后策略参考:System.Web.Mvc, 版本=4.0.40804.0,文化=中性,PublicKeyToken=31bf3856ad364e35 日志:尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/f56977f7/c98ce4c8/System.Web.Mvc.DLL。日志: 正在尝试下载新 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET 文件/root/f56977f7/c98ce4c8/System.Web.Mvc/System.Web.Mvc.DLL。日志: 正在尝试下载新 URL 文件:///D:/RHDHV_Websites/Graafgebiedinformatie/bin/System.Web.Mvc.DLL。 警告:比较程序集名称导致不匹配:修订 编号 ERR:无法完成程序集的设置 (hr = 0x80131040)。 探测终止。

非常感谢任何帮助或提示。谢谢

【问题讨论】:

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


    【解决方案1】:

    我会尝试使用某种消除过程:

    恢复绑定重定向

    1. 确保您在两种环境(本地和远程)上具有相同的 Web 配置
    2. 清理+构建您的项目。进入 bin 环境,获取所有 dll 并将它们粘贴到部署文件夹中。检查 System.Web.Mvc.dll 是否在其中。
    3. 确保在 MVC 项目的引用中引用了 mvc dll。

    远射。将绑定重定向更改为

          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
          </dependentAssembly>
          <dependentAssembly>
    

    您也可以尝试在远程服务器上安装与您的机器相同的 .net 版本,但如果一切都部署得很好,那应该没关系。

    第二个日志是有道理的。它根本找不到要加载的任何 dll,所以它不是不匹配的。

    【讨论】:

    • 我确实按照建议更改了版本并按预期工作。非常感谢
    • 好的,这样你就明白为什么了。我注意到它已加载到第二个日志中,这很可能意味着 4.0.0.0 不在机器上,因此重定向失败:)。很高兴我能帮上忙。
    猜你喜欢
    • 2016-10-14
    • 2014-07-04
    • 1970-01-01
    • 2019-11-03
    • 2013-01-29
    • 1970-01-01
    • 2011-09-01
    • 2018-10-10
    • 1970-01-01
    相关资源
    最近更新 更多