我得到了打开新会话的代码:
ISession OpenSession()
{
if (sessionFactory == null)
{
var cgf = new Configuration();
var data = cgf.Configure(HttpContext.Current.Server.MapPath(@"Models\NHibernate\Configuration\hibernate.cfg.xml")); // Getting error here
cgf.AddDirectory(new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"Models\NHibernate\Mappings")));
sessionFactory = data.BuildSessionFactory();
}
return sessionFactory.OpenSession();
}
但是,我无法初始化'data'变量。可能是什么问题?