无法加载System.Web.Mvc,即使它明显存在且版本正确

时间:2016-02-18 08:05:50

标签: .net asp.net-mvc dll web-deployment external-assemblies

我得到其中一个:

Could not load file or assembly 'System.Web.Mvc, Version=5.0.0.0, 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) 

它继续:

=== Pre-bind state information ===
LOG: DisplayName = System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///D:/Websites/Reporting/2016-02-18.2/
LOG: Initial PrivatePath = D:\Websites\Reporting\2016-02-18.2\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Websites\Reporting\2016-02-18.2\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/reports/7733280c/d5adf208/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/reports/7733280c/d5adf208/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///D:/Websites/Reporting/2016-02-18.2/bin/System.Web.Mvc.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

System.Web.Mvc的正确版本位于D:\ Websites \ Reporting \ 2016-02-18.2 \ bin中。我整夜都在为这个项目而战,但我似乎无法解决这个问题。对于它的价值,我也在web.config中有绑定重定向。

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

我通常都非常擅长dll hell类型的东西,但是这个让我感到困惑,因为据我所知它看起来好像告诉我它无法找到文件& #39; s坐在bin目录中,是它正在寻找的版本。

我从哪里开始?

编辑:我应该指出它在开发中运行良好,当我在开发机器上的某个地方部署项目时它也能正常工作。但是,当我部署到我们的登台服务器时,我得到了这个。不确定可能有什么不同。我确实有一个问题,首先TFS构建正在抓取错误的dll(即使我有复制local = true并且提示路径在那里它仍然抓取不正确的版本,我不得不删除旧的nuget包文件夹以防止这种情况) 。我经常收到这个错误,但这是我第一次拿到它而且当我检查它时文件实际上是正确的版本(并且双倍,三倍和四倍检查它)。

2 个答案:

答案 0 :(得分:0)

我在Views文件夹的web.config中的各个地方使用5.0.0.0。我不明白为什么绑定重定向不会解决这个问题但是当我将它们更新到5.2.3.0时它最终开始工作。

答案 1 :(得分:0)

路径C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\中的dll版本必须具有正确的版本。这是应用程序读取它的位置(来自系统)。你必须更新这个,Else使用Nuget安装所需的版本,这也将更新这个位置dll。并且对于你的评论I should point out that it works fine in development and it also works fine when I deploy the project somewhere on the the development machine.,原因是上面提到的路径中的dll版本是应用程序所需的,因此你没有得到任何错误。