nHibernate和SQLite:Hibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException

时间:2010-12-08 04:45:53

标签: nhibernate sqlite

我在运行时收到以下错误: NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException:持久层中发生异常。    在NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory()

这是配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory >
    <property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
    <property name="connection.connection_string">Data Source=audioHistory.sqlite</property>
    <property name="show_sql">true</property>
    <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
    <property name="proxyfactory.factory_class">
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
   <property name="query.substitutions">true=1;false=0</property>
    <mapping assembly="DataTransfer"/>
  </session-factory>
</hibernate-configuration>

将文件复制到输出目录 我在项目中引用了NHibernate.ByteCode.Castle 在下面的行上失败

Configuration config = new Configuration();
_sessionFactory = config.BuildSessionFactory();  // Fail

任何建议表示赞赏。

2 个答案:

答案 0 :(得分:0)

如果您正在使用NHibernate 2.x,请确保您引用了Castle.Core.dll和Castle.DynamicProxy2.dll。

或者如果您使用的是NHibernate 3.x,请确保您引用了Castle.Core.dll(Castle.DynamicProxy2.dll已不复存在)

答案 1 :(得分:0)

我在一个示例NHibernate项目中尝试了你的配置,我用它来进行演示并且它有效。所以问题就在那里。

验证复制到输出目录的程序集版本是否与NHibernate附带的版本相同。我发现其他库引入了自己的依赖项,包括Castle.Core.dll或NHibernate.ByteCode.Castle.dll的冲突版本。不太可能,但需要检查。