C# 当配置中存在配置行时,Nhibernate.Util导致ProxyFactoryFactoryNotConfiguredException异常
我们正在使用NHibernate和castlewithvalidators项目构建一个项目。我正在尝试将其升级到所有这些版本之间的最新支持版本。我已经让应用程序正常运行,但在下面的几个单元测试中,我发现了一个异常。这些测试实际上并不以任何方式接触数据库,而是测试映射实体周围的功能C# 当配置中存在配置行时,Nhibernate.Util导致ProxyFactoryFactoryNotConfiguredException异常,c#,nhibernate,castle-windsor,nhibernate-validator,C#,Nhibernate,Castle Windsor,Nhibernate Validator,我们正在使用NHibernate和castlewithvalidators项目构建一个项目。我正在尝试将其升级到所有这些版本之间的最新支持版本。我已经让应用程序正常运行,但在下面的几个单元测试中,我发现了一个异常。这些测试实际上并不以任何方式接触数据库,而是测试映射实体周围的功能 NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException: The ProxyFactoryFactory was not confi
NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException:
The ProxyFactoryFactory was not configured.
Initialize 'proxyfactory.factory_class' property of the session-factory
configuration section with one of the available NHibernate.ByteCode providers.
Example:
<property name='proxyfactory.factory_class'>
NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
</property>
Example:
<property name='proxyfactory.factory_class'>
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
</property>
[Continues down stack trace...]
这在之前的NHibernate 2.2版本中没有问题。任何帮助都将不胜感激。在过去的4个小时里,我一直在对它绞尽脑汁。显然,NHibernateUtil不仅需要初始化配置,还需要构建会话工厂。通过手动运行配置并在测试中构建会话工厂,我可以让它正常工作。这在应用程序中不是一个问题,因为会话工厂是手工构建的
var cfg = new NHibernate.Cfg.Configuration().Configure();
var sessionFactory = cfg.BuildSessionFactory();
if (NHibernateUtil.IsInitialized(ChildAssociations))
{
ChildAssociations.ForEach(x => isValid = isValid && x.Element.IsValid(validatedObjects));
}
var cfg = new NHibernate.Cfg.Configuration().Configure();
var sessionFactory = cfg.BuildSessionFactory();