Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a referenced dll from specified location not GAC?

Tags:

.net

I have a dll named A.dll with strong name, another assembly B references A.dll. I place A.dll in c:\myapp, also A.dll is installed in GAC. I hope assembly B loads the A.dll from c:\myapp not GAC. But it always load the A.dll from GAC. My question is how to load a referenced dll from specified local location not GAC. Thanks.

like image 864
ldlchina Avatar asked Aug 13 '10 03:08

ldlchina


2 Answers

According to the MSDN page about how the CLR loads assemblies, the CLR will load assemblies from the GAC before attempting to load assemblies from the working directory. There doesn't appear to be a way around this.

Alternatively, you could just not add the assembly to the GAC so that the CLR would be forced to find the assembly by probing.

like image 174
Kevin Kibler Avatar answered Oct 11 '22 19:10

Kevin Kibler


You'll have to give it a different [AssemblyVersion]. Which ultimately makes sense, if the version numbers are the same then there's no reason that the GAC version wouldn't be good.

like image 37
Hans Passant Avatar answered Oct 11 '22 19:10

Hans Passant