考慮this example作爲基礎示例。我創建了應用程序,但是當我執行此應用程序時出現以下錯誤。使用NHibernate時出錯
The ProxyFactoryFactory was not configured.
初始化「proxyfactory.factory_class」與可用NHibernate.ByteCode提供商之一會話工廠配置部分的屬性。 實施例: 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 = "[email protected]";
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();
}
}
你的配置是什麼樣的? – 2009-06-09 13:02:32
確定我的配置樣子 ?XML版本= 「1.0」 編碼= 「UTF-8」?> <結構> <節 名稱= 「NHibernate的」 類型=「System.Configuration.NameValueSectionHandler,系統,版本= 1.0.5000.0文化=中性公鑰= b77a5c561934e089" /> configSections> –
2009-06-09 13:18:45