views:

669

answers:

3

Hi, 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 NHibernated 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.

+2  A: 

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>
Lachlan Roche
Hi Lachlan..thanks for the help...again. Will give it a try.
Matt
+3  A: 

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.

jishi
From the NHibernate-2.1.2.GA-bin sourceforge.net download.. thanks for the ActiveRecord option.
Matt
Snapping NHibernate bytecode provider from AR is your best option for now, since NHibernate team does not provide updated download for DynamicProxy 2.2
Krzysztof Koźmic