我正在设置我的第一个nHibernate项目。我已经创建了一个简单的web表单,它接受一个名称和一个id,但是,我一直收到以下错误:
未配置ProxyFactoryFactory。使用可用的NHibernate.ByteCode提供程序之一初始化会话工厂配置节的“proxyfactory.factory_class”属性。示例: NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu示例: NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle
我已经在我的项目中添加了对Castle和LinFu的引用。我还将web.config配置为:
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" allowDefinition="Everywhere"/>你能告诉我发生了什么吗?我什么都试过了。是不是我从visualNHibernate导入了很多映射等等?感谢你的帮助。
发布于 2011-04-13 00:10:39
您必须指定要使用的代理工厂,例如:
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>`此外,您发布的cconfiguration包含...没有,请确保有一个最低配置到位,没有它你不能创建NH会话工厂。
发布于 2011-04-13 00:12:20
您需要添加适当的ProxyFactoryFactory,并让NHibernate知道应该使用什么实现来创建代理对象。Fabio不久前在nhibernate.info上发布了如何做到这一点:http://nhibernate.info/blog/2008/11/09/nh2-1-0-bytecode-providers.html,我也强烈建议阅读documentation about configuration of NHibernate。
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="YourAppName">
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.connection_string">
Server=(local);initial catalog=nhibernate;Integrated Security=SSPI
</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>https://stackoverflow.com/questions/5638297
复制相似问题