开发者

nhibernate web.config issues

开发者 https://www.devze.com 2023-02-24 21:38 出处:网络
I am setting up a hibernate project and I keep on getting a proxy error.I have already added the Castle reference to the my project.My web.config has the following:

I am setting up a hibernate project and I keep on getting a proxy error. I have already added the Castle reference to the my project. My web.config has the following:

    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <section name="log4net" type="log4net.Config.Log4NetConfigu开发者_如何学GorationSectionHandler,log4net"/>
</configSections>

<nhibernate xmlns="urn:nhibernate-configuration-2.2">
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Data Source=192.168.1.100, 0000;Initial Catalog=GDER;Persist Security Info=True;User ID=re;Password=none12</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</nhibernate>

Yet, I get the following error consistently

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

The debug always fails here (NHibernate.ISessionFactory factory = config.BuildSessionFactory();):

NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
// add our assembly
config.AddAssembly("nHibernateTest");
// setup nhibernate session
NHibernate.ISessionFactory factory = config.BuildSessionFactory();
NHibernate.ISession session = factory.OpenSession();
// start nhibernate transaction
NHibernate.ITransaction transaction = session.BeginTransaction();

Please help...


You also need to add a reference to the proxy provider in your project (Project > Add Reference... and select NHibernate.ByteCode.Castle.dll).


You're missing a call to config.Configure() before adding the assembly.

0

精彩评论

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