我有一个使用FluentNHibernate的传统WCF服务(沿着EF和存储过程)。这项服务工作了一年多。最近,我们将apppool的回收设置从默认设置更改为每天上午10点进行apppool回收。由于该更改至少两次,我的WCF服务失败并出现以下异常
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> NHibernate.MappingException: Could not configure datastore from input stream (XmlDocument) ---> System.NullReferenceException: Object reference not set to an instance of an object.
at NHibernate.Cfg.MappingsQueue.GetNextAvailableResource()
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
--- End of inner exception stack trace ---
at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String name)
at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
一些有趣的事情需要注意
这很难在本地重现。我已经查看了关于相同异常的以下SO问题,但它们处于完全不同的背景中,这些问题的作者正在一致地获得该异常,而不是这里的情况
Runtime error when trying to run Fluent NHibernate tutorial example
Fluent nHibernate error - Could not compile the mapping document: (XmlDocument)
答案 0 :(得分:0)
经过数小时的调查后,它成了一个尝试创建会话工厂的多线程问题。我本以为NH会话工厂是线程安全的,但遗憾的是它不是,我不得不放入int代码使其成为线程安全的。