相关疑难解决方法(0)

NHibernate需要Proxy Factory吗?

我在hibernate.cfg.xml中进行了这个配置:

<?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.SqlClientDriver</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=SSPI;</property>
    <property name="show_sql">true</property>
  </session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)

我刚刚创建了一个类库,并且我使用MbUnit创建了一个集成测试.它失败.报告的一部分(我认为足够了)在这里:

** NO TESTS WERE RUN (No tests found) **
TestCase 'M:IntegrationTests.RepositoryTests.ListAllPostsReturnsAListOfPost'
failed: The ProxyFactoryFactory was not configured.
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.
Run Code Online (Sandbox Code Playgroud)

我已经阅读了很多教程,并没有看到这个代理工厂配置.指定它真的有必要吗?如果是这样,我该怎么做?我是否要引用其他一些图书馆?

nhibernate nhibernate-configuration

9
推荐指数
1
解决办法
5277
查看次数

NuGet:NHibernate,Castle.Core 3.0和ProxyFactoryFactory在哪里?

我在NuGet上安装了NHibernate和Castle.Core 3.0软件包用于新项目.通常我们手动复制dll; 这是我第一次使用NuGet做到这一点.

现在我无法找到如何配置ProxyFactoryFactory,或者说,我找不到它.我在项目中引用了NHibernate和Castle.Core(我在Castle.Core中找到的唯一一个dll - 包),并配置了以下内容:

<property name="proxyfactory.factory_class">
    NHibernate.ByteCode.Castle.ProxyFactoryFactory, 
    NHibernate.ByteCode.Castle
</property>
Run Code Online (Sandbox Code Playgroud)

这导致:

Class Initialization method Tests.UnitTest1.MyClassInitialize threw exception.
NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException:
NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable
to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Run Code Online (Sandbox Code Playgroud)

显然这个dll丢失了,但我在哪里可以找到它?NuGet中有一个包叫Castle.DynamicProxy,但它被标记为已过时.

ps:在Castle.Core 3.0 - 包的描述中,据说:...包括DynamicProxy ...

nhibernate castle castle-dynamicproxy nuget nuget-package

5
推荐指数
1
解决办法
5027
查看次数