Error deploying NHibernate on ASP.NET

I am trying to embed NHibernate in my web application. I am facing an error that says:

Method "IsInstrumented" in type "NHibernate.ByteCode.Castle.ProxyFactoryFactory" from the assembly 'NHibernate.ByteCode.Castle, Version = 2.1.2.4000, Culture = Neutral,
PublicKeyToken = aa95f207798dfdb4 'has no implementation.

Does anyone know how to solve this problem?

+4
source share
1 answer

Make sure that you have the following DLL files copied to the output folder and loaded using w3wp.exe (if you are using IIS):

  • NHibernate.ByteCode.Castle.dll
  • Castle.Core.dll
  • NHibernate.dll
  • Iesi.Collections.dll
  • log4net.dll

And your NHibernate configuration has the following line:

<property name="proxyfactory.factory_class"> NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle </property> 

As an option, you can try upgrading to the latest version of NHibernate - 3.2. They have a built-in proxy generator, so it should be easier for you. You do not need these additional DLLs. Just delete the configuration line above if you are using NHibernate 3.2.

If for some reason you cannot upgrade to 3.2, you can consider using byte code providers . NHibernate supports 3 of them out of the box. Try LinFu or Spring:

  • NHibernate.ByteCode.Castle.ProxyFactoryFactory
  • NHibernate.ByteCode.LinFu.ProxyFactoryFactory
  • NHibernate.ByteCode.Spring.ProxyFactoryFactor
+5
source

All Articles