在ASP.NET网站中实现NHibernate时出错

TJ.*_*TJ. 4 nhibernate

我正在尝试将NHibernate实现到我的Web App中.我遇到一个错误说:

程序'NHibernate.ByteCode.Castle.ProxyFactoryFactory'中的方法'IsInstrumented'来自程序集'NHibernate.ByteCode.Castle,Version = 2.1.2.4000,Culture = neutral,
PublicKeyToken = aa95f207798dfdb4'没有实现.

有谁知道如何解决这个问题?

Dmi*_*try 5

确保将以下dll复制到输出文件夹并由w3wp.exe 加载(如果使用IIS):

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

你的NHibernate配置有这一行:

<property name="proxyfactory.factory_class">
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
</property>
Run Code Online (Sandbox Code Playgroud)

作为选项,您可以尝试升级到最新版本的NHibernate - 3.2.他们有一个内置的代理生成器,所以它应该更简单.你不需要这些额外的dll.如果您使用NHibernate 3.2,只需删除上面的配置行.

如果由于某些原因您无法升级到3.2,则可以考虑使用不同的字节代码提供程序.NHibernate支持其中3个开箱即用.试试LinFu或Spring:

  • NHibernate.ByteCode.Castle.ProxyFactoryFactory
  • NHibernate.ByteCode.LinFu.ProxyFactoryFactory
  • NHibernate.ByteCode.Spring.ProxyFactoryFactor