获取错误打开会话

时间:2014-02-11 13:53:23

标签: c# asp.net-mvc nhibernate visual-studio-2012

我得到了打开新会话的代码:

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'变量。可能是什么问题?

0 个答案:

没有答案