As an alternative to the proposed solution, during development you can bind to whatever assembly you want overriding the GAC completely by setting the DEVPATH
environment variable and enabling Development Mode in the machine.config
. I think this is by far the easiest way to achieve what you want, but should not be used in production.
This solves the issue where version of your assembly and the one in the GAC are the same, if versions are different, you should use the bindingRedirect
approach mentioned here by several users.
First, add the following to machine.config
:
<configuration>
<runtime>
<developmentMode developerInstallation="true"/>
</runtime>
</configuration>
Then, set the DEVPATH
environment variable to the location of your non-signed assemblies. This will force Fusion's DEVOVERRIDE mode to kick in and search the DEVPATH
(and its subdirectories) prior to probing the GAC.
An FAQ of DEVPATH
and DEVOVERRIDE
on MSDN will answer most questions on the effects of using this.
Fusion (.NET's assembly loader) will search by name and version only, it will treat strongly named assemblies equal to other assemblies, won't search the GAC before searching DEVPATH
, and simply returns the first match found. You should use the Fusion Log Viewer (fuslogvw) to see that you properly enabled it, as explained in this blog post on DEVPATH
.
New to using FusLogVw? Scott Hanselman wrote an excellent intro. The interface of the Viewer is rather archaïc and takes a little getting used to.
Note that the Fusion Log Viewer (or Assembly Binding Log Viewer, what's in a name) will confusingly say that you used the DEVOVERRIDE
environment variable. It should look something like this:
LOG: Found assembly in DEVOVERRIDE path D:\testassemblies\Test.DLL
NOTE: if you want Visual Studio to load the assemblies from the DEVPATH
location, you should set a registry key to this location, i.e., set (check the .NET version key to match your .NET version):
[HKEY_CURRENT_USER\
SOFTWARE\
Microsoft\
.NETFramework\
v2.0.50727\AssemblyFoldersEx\
DEVPATH]@="C:\SharedAssemblies"