3
votes

I am having an issue getting Hibernate and Windsor to work together. My setup details are as follows

I have two projects
-DomainModel
-MVCApp

I have downloaded NHibernate 2.1.2 and Windsor 2.1.1
I added the following references to DomainModel from the required_Bins folder of the NHibernate download -
Antlr3,Iese,log4net and NHibernate 2.1.2.4
I also added references in DomainModel to files for Lazy_loading including

Castle.Core - 1.1.0.0
Castle.DynamicProxy2 - 2.1.0.0
NHibernate.ByteCode.Castle - 2.1.2.4

The MVCApp has the following references:

Castle.Core - 1.2.0.6623
Castle.Microkernel - 2.1.0.6655
Castle.Windsor - 2.1.0.6655
Castle.DynamicProxy2 - 2.2.0.6628

When running the app I get the Error :

Could not load file or assembly 'Castle.DynamicProxy2, Version=2.1.0.0,
Calling assembly : NHibernate.ByteCode.Castle, Version=2.1.2.4000

The MVC bin folder has the Castle.DynamicProxy2 - 2.2.0.6628 version, hence the error after the older version was requested.

How do I go about getting this to work? What am I missing or including incorrectly? Please help.. Thanks.

4

4 Answers

3
votes

From where did you get your NHibernate.ByteCode.Castle?

I believe that ActiveRecord 2.1 will have one built for the latest stable release of DynamicProxy2.

Otherwise, do what Lachlan Roche suggests.

2
votes

You could get the source for NHibernate.ByteCode.Castle and build a version that uses version 2.2.0.6628 of Castle.DynamicProxy2. The 2.1.x branch is here in svn.

It is also possible that an assembly binding redirect may work. This could fail due to API difference between 2.1 and 2.2 of Castle.DynamicProxy2.
You would also update the assembly references in your MVCApp project.

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="Castle.DynamicProxy2" publicKeyToken="407dd0808d44fbdc"/>
            <bindingRedirect oldVersion="2.1.0.0" newVersion="2.2.0.6628"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>
0
votes

I had this issue, you may have to change your "Target framework" on the application tab of your project properties from ".NET Framework 4 Client Profile" to ".NET Framework 4"

0
votes

I had the same problem...and I solved it by changing the NHibernate Bytecode provider.
When I started using NHibernate, I chose the Castle Bytecode provider for no specific reason.

Since I don't care which Bytecode provider I actually use, I just changed it (in my case to NHibernate.ByteCode.LinFu).
So NHibernate doesn't need any references to Castle anymore, and I can use whatever version of Windsor I want.