R – How to recompile Sharp Architecture library to use NHIbernate 2.1.0.4000 instead of 2.1.0.3001

nhibernatereferences#arp-architectureversion

I have updated the Sharp Architecture solution (SharpArchitecture_1.0_RTM_build_486) (my local copy) and referenced NHibernate 2.1.0.4000 instead of NHibernate 2.1.0.3001 dll. I have also updated all other NHibernate related references in Sharp Architecture solution.

I was able to rebuild Sharp Architecture and to pass all the tests using the NHibernate version 2.1.0.4000. I have used the provide build script.

When I update the references (NHibernate and recompiled Sharp dlls) in my application and try to initialize NHibernate, the application is throwing "Could not load file or assembly 'NHibernate, Version=2.1.0.3001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

This error is thrown in NHibernateSession.Init method. The calling assembly is SharpArch.Data.

Besides recompiling the Sharp Architecture with new dlls, is there something else that needs to be done? The Sharp Architecture is strongly typed against NHibernate 2.1.0.3001.

The reason why I'm doing this is because I want to include NHibernate.Cache in my application. The NHibernate.Cache is compiled against NHibernate 2.1.0.4000 (NHibernate-2.1.0.GA-bin)

Best Answer

Add the following within your web.config file before the opening of the system-web tag.

 <runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
       <assemblyIdentity name="NHibernate" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-2.1.0.3001" newVersion="2.1.0.4000"/>
   </dependentAssembly>
 </runtime>

This should solve the problem.