【发布时间】:2012-03-06 23:29:58
【问题描述】:
我遇到了一个问题,即在 bin 中使用的是较旧的 GAC 程序集,而不是较新版本的程序集。
服务器:
Assembly version: ASP.NET MVC 3 RC 1 (3.0.11029.0)
Full name: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Web.Mvc/v4.0_3.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed
开发机器:
Assembly version: Unknown version (3.0.20105.0)
Full name: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Mvc/v4.0_3.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed
较新的 RTM 版本 (3.0.20105.0) 位于应用程序的 bin 目录中。但是,应用程序使用的是 GAC 中的那个,而不是本地 bin。我在 Windows 应用程序中的经验是本地 bin 部署的 DLL 始终优先,因为只有在与应用程序位于同一目录中未找到 DLL 时才会检查 GAC。这个约定似乎不适用于 Web 应用程序。
如何强制它使用我较新版本的 bin 部署的 DLL (3.0.20105.0)?
编辑: 我实际上确实尝试过这样的绑定重定向:
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="3.0.11029.0" newVersion="3.0.20105.0" />
我在旧版本上尝试了几种变体,例如0.0.0.0-4.0.0.0。在我所有的尝试中,它通常要么加载旧版本,要么给我这个异常消息:
Could not load file or assembly 'System.Web.Mvc' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
绑定日志没有任何错误,除了最后两行:
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
【问题讨论】:
标签: asp.net asp.net-mvc-3 web-config gac assembly-resolution