I have the following situation
Project A
- Uses Castle Windsor v2.2 - Uses Project B via WindsorContainer
Project B
- Uses NHibernate - Uses Castle Windsor v2.1
In the bin folder of Project A I have the dll Castle.DynamicProxy2.dll v2.2 and NHibernate dlls. Now the problem is that NHibernate is dependent on Castle.DynamicProxy2.dll v2.1 which is not there. How do I resolve this situation.
Because the strong-named assembly's version number is part of its identity, the runtime can store multiple versions of the same assembly in the global assembly cache and load those assemblies at run time.
An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (. dll) files, and are the building blocks of . NET applications.
I used the following configuration to resolve the issue.
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Castle.DynamicProxy2" publicKeyToken="407dd0808d44fbdc" /> <codeBase version="2.1.0.0" href="v2.1\Castle.DynamicProxy2.dll" /> <codeBase version="2.2.0.0" href="v2.2\Castle.DynamicProxy2.dll" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" /> <codeBase version="1.1.0.0" href="v2.1\Castle.Core.dll" /> <codeBase version="1.2.0.0" href="v2.2\Castle.Core.dll" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
One thing very, very, very important that one might miss if he is not paying enough attention.
The assembly you write in the codeBase version tag, must be strong named.
From the following link: http://msdn.microsoft.com/en-us/library/efs781xb.aspx
For assemblies without a strong name, version is ignored and the loader uses the first appearance of <codebase> inside <dependentAssembly>. If there is an entry in the application configuration file that redirects binding to another assembly, the redirection will take precedence even if the assembly version doesnt match the binding request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With