比较程序集名称会导致不匹配:修订号

时间:2019-09-25 06:20:00

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

我正在使用ASP.NET MVC4应用程序,该应用程序在我的本地计算机上可以正常工作,但在应用程序服务器上不起作用,并引发以下错误:

  

无法加载文件或程序集'System.Web.Mvc,Version = 2.0.0.0,   文化=中性,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。   日志:目前未将政策应用于引用(私有,   自定义,部分或基于位置的程序集绑定)。日志:尝试   下载新网址   文件:/// C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary   ASP.NET文件/root/f56977f7/c98ce4c8/System.Web.Mvc.DLL。日志:   尝试下载新的URL   文件:/// 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。日志:政策后参考:System.Web.Mvc,   版本= 4.0.40804.0,文化=中性,PublicKeyToken = 31bf3856ad364e35   日志:尝试下载新的URL   文件:/// C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary   ASP.NET文件/root/f56977f7/c98ce4c8/System.Web.Mvc.DLL。日志:   尝试下载新的URL   文件:/// 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。   WRN:比较程序集名称导致不匹配:修订   编号ERR:无法完成装配的设置(hr = 0x80131040)。   探测终止。

任何帮助或提示都将不胜感激。谢谢

1 个答案:

答案 0 :(得分:0)

我会尝试使用某种消除方法:

还原绑定重定向

  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,因此这不是错配。

相关问题