将此示例视为基本示例。我创建了应用程序,但是当我执行此应用程序时出现以下错误。
The ProxyFactoryFactory was not configured.
使用可用的 NHibernate.ByteCode 提供程序之一初始化会话工厂配置部分的“proxyfactory.factory_class”属性。示例:NHibernate.ByteCode.LinFu.ProxyFactoryFactory、NHibernate.ByteCode.LinFu 示例:NHibernate.ByteCode.Castle.ProxyFactoryFactory、NHibernate.ByteCode.Castle
以下是我正在使用的代码片段。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NHibernate;
using NHibernate.Cfg;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Configuration cfg = new Configuration();
cfg.AddAssembly("NHibernate");
ISessionFactory factory = cfg.BuildSessionFactory(); //getting error at this line
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;
// Tell NHibernate that this object should be saved
session.Save(newUser);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}
}