开发者

nHibernate ProxyFactory issues

I am setting up my first n开发者_运维技巧Hibernate project. I have created a simple web form that accepts a name and an id however, I keep on getting the following error:

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: NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu Example: NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle

I have already added the references to both Castle and LinFu to my project. I have also configured the web.config to the following:

<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" allowDefinition="Everywhere"/>

Can you tell me what is going on? I have tried everything. Is it that I imported a lot of my mappings etc, from visualNHibernate? Appreciate the help.


You have to specify what proxy factory you intend to use, as for example:

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

And, furthermore, the cconfiguration you posted contains... nothing, please ensure to have a minimum configuration in place, without it you can't create the NH session factory.


You need to add the proper ProxyFactoryFactory and let NHibernate know what implementation should be used to create proxy objects. Fabio posted how to do it a while ago over at nhibernate.info: http://nhibernate.info/blog/2008/11/09/nh2-1-0-bytecode-providers.html I also strongly suggest to read the 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜