この例を基本例と考えてください。アプリケーションを作成しましたが、このアプリケーションを実行すると次のエラーが発生します。
The ProxyFactoryFactory was not configured.
使用可能な NHibernate.ByteCode プロバイダーの 1 つを使用して、session-factory 構成セクションの「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();
}
}