views:

330

answers:

5

I have developed a console utility that performs some operations against a server application. Due to the nature of the server app I'm working with, I need to execute this utility on the server.

The problem is that the utility is referencing a common DLL that has previously been deployed to the server's GAC. Since the common DLL's deployment, it has been updated and my utility relies on these updates. I am unable to update the DLL in the GAC due to company policy regarding deployment.

By default my utility will use the outdated DLL in the GAC. Is there a way I can force it to use the updated DLL (e.g. by specifying a path on the file system)?

A: 

You might want to take a look at the AppDomain.AssemblyResolve event.

EDIT: the event is only fired when regular assembly resolution fails, so it does not fit your needs.

Dario Solera
That only happens if it *fails*; so if version in the GAC matches name/version/signature, you won't see this event.
Marc Gravell
You are right - my bad.
Dario Solera
Not sure it warranted a down-vote, though. Balanced that up for you ;-p
Marc Gravell
+2  A: 

The Assembly class has some methods to load assemblies from specific locations.

Assembly.LoadFrom has a few overloads

EDIT: There is a way to specify, via configuration file, where to look for specific assembly versions. I can't recall exactly.

Megacan
If you have any further information on the configuration file method that would be great.
Alex Angas
http://msdn.microsoft.com/en-us/library/7wd6ex19(vs.71).aspxAssembly binding and assembly base tags. Hope it helps
Megacan
+3  A: 

Does the updated DLL not have a new version number? I would expect that if you force the reference to use the right version number, it should pick up the local one.

Jon Skeet
Downvoters: Comments are helpful...
Jon Skeet
+3  A: 

Unfortunately, GAC tends to play a trump card - but if you have changed the version, then the GAC resolve should fail (as long as you have "Specific Version" set to true in the IDE), allowing it to load the local version?

Marc Gravell
A: 

Try using a <codebase> element in the app.config

foson