问题
I've got a C# application which refers to a .NET DLL.
If this DLL is present both in my application's bin
directory and GAC, then
which one will be picked up by the CLR at runtime? If GAC has the latest version, would that version be used instead of the one present in bin
?
And how do I force the CLR to always use the one in my bin
instead of GAC?
According to MSDN:
The CLR checks the global assembly cache, codebases specified in configuration files, and then checks the application's directory and subdirectories.
So, does that mean it looks into GAC first?
Thanks.
回答1:
You force the CLR to not use a copy of an assembly in the GAC by not having it in the GAC. Simple to do by renaming the DLL or by changing its [AssemblyVersion] before referencing it in your project. Skipping this invokes nasty runtime exceptions, otherwise known as DLL Hell.
来源:https://stackoverflow.com/questions/11593394/dll-used-by-clr-at-runtime