4

I am having a problem where an older GAC'd assembly is being used instead of a newer version assembly in the 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. However, the application is using the one in the GAC instead of the local 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. This convention appears to not be the case for a web application.

How can I force it to use my newer version bin deployed 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. 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.
Joshua
  • 4,099
  • 25
  • 37
AaronLS
  • 37,329
  • 20
  • 143
  • 202

2 Answers2

1

Answered is SO Dll in both the bin and the gac, which one gets used? Note, you must run strong name hijack or it will use the GAC version. I would retag this, it is not MVC specific.

Community
  • 1
  • 1
RickAndMSFT
  • 20,912
  • 8
  • 60
  • 78
  • I'm confused. In the linked question it indicates if I compile against a newer version than is in the GAC, and bin deploy that same newer version, then it should take precedence over the GAC. This describes my scenario, except unfortunately the behavior is not as they describe, as it is ignoring my newer/compiled against bin version in favor of the GAC version. – AaronLS Mar 09 '12 at 01:22
  • 1
    What is a strong name hijack? I am familiar with using the sn tool on my own assemblies, but am not sure what you are implying I do with the MS assembly? – AaronLS Mar 09 '12 at 01:24
0

You can modify your .config files to use assembly binding redirection for this and force the runtime to load different versions as you require.

kprobst
  • 16,165
  • 5
  • 32
  • 53