【问题标题】:A session factory has already been configured with the key of nhibernate.current_session已经使用 nhibernate.current_session 的键配置了会话工厂
【发布时间】:2009-08-13 14:28:38
【问题描述】:

注意:我也在sharp architecture google groups上发布了这个。

描述:执行过程中发生了未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。

异常详细信息:SharpArch.Core.PreconditionException:一个会话 工厂已经配置了密钥 nhibernate.current_session

来源错误:

第 49 行:base.Init(); 第 50 行: 第 51 行:NHibernateSession.Init(new WebSessionStorage (这), 第 52 行:新字符串 [] { Server.MapPath("~/bin/ GCBA.Data.dll") }); 第 53 行:}

源文件:C:\Users\Matt\Desktop\Matt\GCBA\GCBA\GCBA.Web \Global.asax.cs 行:51

堆栈跟踪:

[PreconditionException: 已经配置了会话工厂 使用 nhibernate.current_session 的键]

SharpArch.Core.Check.Require(Boolean assertion, String message) in C:\MyStuff\Projects\SharpArchitecture\src\SharpArch\SharpArch.Core \DesignByContract.cs:62

SharpArch.Data.NHibernate.NHibernateSession.Init(ISessionStorage 存储,String[] mappingAssemblies,AutoPersistenceModel autoPersistenceModel,字符串 cfgFile,IDictionary`2 cfgProperties, String validatorCfgFile, IPersistenceConfigurer persistenceConfigurer) 在 C:\MyStuff\Projects\SharpArchitecture\src\SharpArch\SharpArch.Data \NHibernate\NHibernateSession.cs:70

SharpArch.Data.NHibernate.NHibernateSession.Init(ISessionStorage storage, String[] mappingAssemblies) 在 C:\MyStuff\Projects \SharpArchitecture\src\SharpArch\SharpArch.Data\NHibernate \NHibernateSession.cs:26

GCBA.Web.MvcApplication.Init() 在 C:\Users\Matt\Desktop\Matt\GCBA \GCBA\GCBA.Web\Global.asax.cs:51

System.Web.HttpApplication.InitInternal(HttpContext 上下文, HttpApplicationState 状态,MethodInfo[] 处理程序)+335


这是我尝试从 IIS7 运行时出现的错误...我可以正常运行 似乎没有 VS2008 Cassini ......所以我不确定是什么问题 是,我有 S#arp 和 MVC.Net 1.0 的 7/16/2009 主干构建。这 它失败的一段代码在 global.asax.cs Init() 方法。我真的对这个问题感到非常沮丧,因为我有 只找到了另一篇关于此的帖子,它在测试用例中, 我实际上是在尝试从 iis7 和所有网站运行网站 我的测试通过了。

如果有人知道可能导致此问题的原因,那将是 太好了谢谢。

【问题讨论】:

    标签: asp.net-mvc nhibernate s#arp-architecture


    【解决方案1】:

    我最近遇到了同样的问题。我使用了 S#arp arch 但使用了普通的 asp.net 网站项目(集成在 cms 中)。对我来说,整个问题是 Global.asax 不会在未知文件类型或虚拟 url 上触发。我通过编写自己的 HttpModule 并单独加载它来解决它,这具有启动 NHibernate 的副作用,即使有人只获取图像。但对我来说这不是问题。

    希望这能让你朝着正确的方向前进......

    【讨论】:

      【解决方案2】:

      这听起来像是没有为 ASP.NET MVC 正确配置 IIS7。 See if this post on SO 帮助您使用 ASP.NET MVC 设置 IIS7。我也在使用 SharpArchitecture,在 IIS7 以“集成”模式运行后,解决了很多问题。

      【讨论】:

        【解决方案3】:

        可能是线程问题?

        你有没有在你的应用初始化中尝试过这样的事情:

        private static bool haveInit
        if (!haveInit)
        {
            lock (@lock)
            {
                if (!haveInit))
                {
                    NHibernateSession.Init(...);
                    haveInit = true;
                }
            }
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-08-22
          • 1970-01-01
          • 2021-06-21
          • 1970-01-01
          相关资源
          最近更新 更多