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. | |||
|
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.
| |||||||
|
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. | |||||||
|
The only way is by using Assembly.LoadFile() to load your assembly. This allows you to specify a path to load. There are several gotchas that make this very painful:
| |||
|
It is possible to do this by hosting the CLR and implementing IHostAssemblyManager and IHostAssemblyStore. This is like using a bazooka to kill a mosquito though. | |