给定关键字不在字典中,ISessionFactory factory = cfg.BuildSessionFactory();
刚学Nhibernate框架,就出了问题,哪位大虾指点一下,在线等,错误是:
用户代码未处理 System.Collections.Generic.KeyNotFoundException
Message="给定关键字不在字典中。"
Source="mscorlib"
StackTrace:
在 System.ThrowHelper.ThrowKeyNotFoundException()
在 System.Collections.Generic.Dictionary`2.get_Item(TKey key)
在 NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) 位置
c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Dialect\Dialect.cs:行号
173
在 NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties) 位置
c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Cfg\SettingsFactory.cs:行
号 32
在 NHibernate.Cfg.Configuration.BuildSettings() 位置
c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Cfg\Configuration.cs:行号
1424
在 NHibernate.Cfg.Configuration.BuildSessionFactory() 位置
c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Cfg\Configuration.cs:行号
983
在 _Default.Button1_Click(Object sender, EventArgs e) 位置 c:\Documents and
Settings\Administrator\桌面\新建文件夹\TZservice\WebSite1\Default.aspx.cs:行号 30
在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
(String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String
eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("TZService.Model");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
session = factory.OpenSession();
UserInfo item = new UserInfo();
item.UseName = "zhouwu";
item.Md5Password = "123456";
item.UpperUseName = "ZHOUWU";
session.Save(item);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();