7

It is my understanding that .NET runtime will always look for referenced assemblies in GAC first and then in the local folders. Is there a setting in Web.Config that would invert this order?

starblue
  • 55,348
  • 14
  • 97
  • 151

4 Answers4

17

No. It's not possible to achieve this. If a DLL of equal version to the one referenced in your program exists in the GAC the CLR will always choose this one. There is no way to override this behavior.

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • Is it something to do with security? – codeulike May 05 '09 at 21:38
  • @codeulike, i believe it has more to do with servicing. I know less about the why and more about the ability to do so because I spent a lot of time trying to subvert this behavior before realizing it simply wasn't possible. – JaredPar May 05 '09 at 21:39
  • 5
    This is why the GAC is evil, in my book. – Benjol May 06 '09 at 06:59
3

More info. on work arounds in this SO thread.

Community
  • 1
  • 1
JP Alioto
  • 44,864
  • 6
  • 88
  • 112
2

I'm not sure if there's something that will actually reverse the search order as such, but depending on your requirements you might want to look into assembly binding redirection which gives you quite a lot of control over which versions of assemblies are loaded.

Steve Willcock
  • 26,111
  • 4
  • 43
  • 40
1

JaredPar is right - the GAC will always get polled first for the assembly. However, if you're like me, and want to have the DLL live in the GAC and still debug, you can add a build script to dump your .pdb file the same folder as the assembly in the GAC (it'll be in C:\windows\assembly\gac_msil\assembly.name_[public key token]).

Adam McKee
  • 802
  • 2
  • 8
  • 14