NHibernate异常集锦

NHibernate异常集锦

异常:

The ProxyFactoryFactory was not configured.
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.
Example:
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
Example:
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>

解决方法:

第一步:添加两个数据集(NHibernate.ByteCode.Castle.dll,NHibernate.ByteCode.LinFu.dll)的引用

第二步:在hibernate.cfg.xml配置文件中加入这两个节点:

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

异常:

NHibernate.Proxy.CastleProxyFactory”的类型初始值设定项引发异常

{"未能加载文件或程序集“Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc”或它的某一个依赖项。系统找不到指定的文件。":"Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc"}

解决方法:

添加对Castle.DynamicProxy.dll程序集的引用

异常:

未能加载文件或程序集“NHibernate, Version=3.0.0.1002, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

解决方法:

这是添加引用的NHibernate版本是3.0.0.1002造成问题

找到对应版本的NHibernate.dll,然后添加引用


异常:

未能加载文件或程序集“Domain”或它的某一个依赖项。系统找不到指定的文件。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 
异常详细信息: System.IO.FileNotFoundException: 未能加载文件或程序集“Domain”或它的某一个依赖项。系统找不到指定的文件。 
解决方法:

检查在hibernate.cfg.xml中 <mapping assembly="Domain"/> assembly属性值是程序集名称(也就是你所创建的Model对应的dll的名称)

原文地址:https://www.cnblogs.com/lonlywaiting/p/3279221.html