One solution (or workaround) would be to install both versions in the Global Assembly Cache (GAC) on the machine(s) on which your software needs to run, and reference the assemblies using their strong names. This assumes that the assemblies do indeed have strong names.
Installing into the GAC will be a pain if you have more than a few developers or if you plan to deploy your solution to many computers (eg as an end-user application). In this case, I believe (but I might be wrong) that your only option is to merge one of the two versions into the assembly requiring that version. In your specific case, you need Castle.DynamicProxy2.dll
v2.1 to be merged into NHibernate.dll
.
You can use a tool called ILMerge to merge the assemblies. The command you will need to run looks something like this (untested):
ILMerge /t:library /internalize /out:Deploy/NHibernate.dll
NHibernate.dll Castle.DynamicProxy2.dll
The /internalize
switch tells ILMerge to mark all types from the second assembly (Castle in this case) internal
in the output assembly. Without this, you might get compile errors when you try to compile a project referencing both your new NHibernate.dll
and the shelf version of Castle.DynamicProxy2.dll
v2.2, as they will contain classes with the exact same names.