Error loading one of the NHibernate dependent dll's

k.c. picture k.c. · Aug 2, 2011 · Viewed 8k times · Source

I am building an application using NHibernate. Because I could not add the DLL's of my current version of NHibernate (I cannot add reference when framework 4.0 is target).

I tried to get the latest and greatest of the w.w.w., this is what I have now:

  • NHibernate.dll (3.2.0.4000)
  • NHibernate.ByteCode.Castle (3.0.0.4000)
  • FluentNHibernate.dll (1.2.0.694)
  • Castle.Core (2.5.2.0)
  • Castle.Services.Logging.NLogIntegration (2.5.2.0)
  • Antlr.Runtim (3.1.3.42154)
  • Iesi.Collections (3.2.0.400)

These I can reference and build my solution with. I know there are some issues with the copying/loading of the dll.s so I made them deployment items. But run-time I (still) get the following:

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class. Possible causes are: - The NHibernate.Bytecode provider assembly was not deployed. - The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.

Solution:

Confirm that your deployment folder contains one of the following assemblies:

NHibernate.ByteCode.LinFu.dll NHibernate.ByteCode.Castle.dll ---> System.TypeLoadException: Method 'IsProxy' in type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory' from assembly 'NHibernate.ByteCode.Castle, Version=3.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' does not have an implementation.

Thoughts anyone?

In response to Vijay Gill’s answer I have decided to take a different tack.

NUGet packages, a one-stop shop, and easy updates!

There is a FluentNHibernate package out there. I have installed it but I guess there is something amiss here too:

Test method CoreDatabaseTests.CreateCoreDatabase threw exception:

System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=3.2.0.4000, 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) ---> System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

Answer

Mauricio Scheffer picture Mauricio Scheffer · Aug 2, 2011

With NHibernate 3.2 you don't need NHibernate.ByteCode.Castle anymore, which considerably simplifies your dependency tree.