{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("NhibernateConsole");
ISessionFactory isessionfactory = cfg.BuildSessionFactory();
ISession isession = isessionfactory.OpenSession();
ITransaction itransaction = isession.BeginTransaction();
User user = new User();
user.Name = this.name.Text.Trim();
user.Pwd = this.password.Text.Trim();
try
{
isession.Save(user);
label1.Text = "Add Successfully";
}catch(Exception ex)
{
this.label1.Text = ex.Message;
}
}
}
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>
错误信息告诉你怎么做了:
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>
补充hibernate.cfg.xml文件session-factory configuration节点
http://www.cnblogs.com/virusswb/archive/2010/01/08/1642402.html