3
我们正在使用NHibernate和Castle与Validators项目构建项目。我试图将它升级到所有这些之间的最新支持版本。我已经使应用程序正常工作,但是在我的一些单元测试中我得到了下面的例外。这些测试实际上并不以任何方式触及数据库,而是围绕映射实体测试功能。Nhibernate.Util在config中存在配置行时导致ProxyFactoryFactoryNotConfiguredException
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...]
下面是我的配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="Linx2">
<property
name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property>
<property name="dialect">Linx2.Common.Framework.PostgreSQL83Dialect,
Linx2.Common.Framework</property>
<property name="connection.connection_string">[Hidden so I don't get fired.]</property>
<property name="adonet.batch_size">10</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="command_timeout">60</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="proxyfactory.factory_class">
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
</property>
<property name="connection.release_mode">after_transaction</property>
<mapping assembly="NHibernate.Collection.Observable" />
</session-factory>
</hibernate-configuration>
我的配置映射那里,它在应用程序的工作。我还包括NHibernate.ByteCode DLL。但是,在这些测试中,它被忽略。我尝试过在单个测试中手动启动配置,甚至停止并确认配置中包含该项目的中间测试。但是,在IsInitialized调用中的下面的代码中引发了异常。
if (NHibernateUtil.IsInitialized(ChildAssociations))
{
ChildAssociations.ForEach(x => isValid = isValid && x.Element.IsValid(validatedObjects));
}
这工作以前没有任何问题在NHibernate建设为2.2。任何帮助将不胜感激。在过去的4个小时里,我一直在为此付出代价。