简体   繁体   English

Bin为Web应用程序部署了DLL优先于GAC的DLL?

[英]Bin deployed DLLs priority over GAC'd DLL's for Web app?

I am having a problem where an older GAC'd assembly is being used instead of a newer version assembly in the bin. 我遇到的问题是使用较旧的GAC程序集而不是bin中较新的版本程序集。

Server: 服务器:

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 

Development machine: 开发机器:

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 

The newer RTM version (3.0.20105.0) is in the bin directory of the application. 较新的RTM版本(3.0.20105.0)位于应用程序的bin目录中。 However, the application is using the one in the GAC instead of the local bin. 但是,应用程序正在使用GAC中的那个而不是本地bin。 My experience from windows applications is the local bin deployed DLL always takes precedence because the GAC is checked only if the DLL isn't found in the same directory as the application. 我从Windows应用程序的经验是本地bin部署的DLL始终优先,因为只有在与应用程序相同的目录中找不到DLL时才会检查GAC。 This convention appears to not be the case for a web application. 对于Web应用程序,此约定似乎不是这种情况。

How can I force it to use my newer version bin deployed DLL (3.0.20105.0)? 如何强制它使用我的新版本bin部署DLL(3.0.20105.0)?

Edit: I actually did try a binding redirect like so: 编辑:我确实尝试过像这样的绑定重定向:

<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="3.0.11029.0" newVersion="3.0.20105.0" />

I tried several variations on the oldversion such as 0.0.0.0-4.0.0.0 . 我试图在oldversion等几种变化0.0.0.0-4.0.0.0 In all my attempts usually it either loaded the older version, or gave me this exception message: 在我的所有尝试中,通常它会加载旧版本,或者给我这个异常消息:

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. 

The binding log didn't have any errors except this was last two lines: 绑定日志没有任何错误,除了这是最后两行:

WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Answered is SO Dll in both the bin and the gac, which one gets used? 回答是bin和gac中的 SO Dll,哪一个被使用? Note, you must run strong name hijack or it will use the GAC version. 注意,您必须运行强名称劫持 ,否则它将使用GAC版本。 I would retag this, it is not MVC specific. 我会重申这一点,它不是MVC特有的。

您可以修改.config文件以使用程序集绑定重定向 ,并强制运行时根据需要加载不同的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM