tags:

views:

332

answers:

1

Hi

I am new NHibernate.I am writing the simple application that have cusstomer class contains id and name and using nhibernate i am storing the object to database. but i am getting the following

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>

after reading this error i added reference NHibernate.ByteCode.Castle to my application.still i am getting the error .and i declared in cfg.xml file

hibernate.cfg.xml file

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=(local);Initial Catalog=Customer;User Id=sa;Password=myPassword1</property>

  </session-factory>
</hibernate-configuration>

customer.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ConsoleApplication1" assembly="ConsoleApplication1">
  <class name="ConsoleApplication1.Customer" table="Customer">
    <id name="Id" type="string" length="40">
      <generator class="assigned"></generator>

    </id>
    <property name="Name" column="Name" type="String" length="40"></property>

  </class>

</hibernate-mapping>

main function

Configuration cfg = new Configuration();
cfg.AddAssembly(Assembly.GetCallingAssembly());

ISessionFactory factoty = cfg.BuildSessionFactory();
ISession session = factoty.OpenSession();
ITransaction TRANS = session.BeginTransaction();

Customer newCustomer = new Customer();
newCustomer.ID = "1";
newCustomer.Name = "test";

session.Save(newCustomer);
session.Close();

can anyone help me? thanks in advance

A: 

Same issue, same resolution attempts. All of the referenced DLLs are set to copy local and are in the project. I am using a hibernate.cfg.xml file with Castle as my proxy factory.

Curiously, this only occurs when I use a SessionFactory to create my Session. If I switch to my other test classes where I instantiate a session via FluentNHibernate.SessionSource (PersistenceModel), I don't receive this error.

Kurt Johnson