Nhibernate 2.1.0有什么问题?我总是有一个错误!
-
18-09-2019 - |
题
我在这篇文章中读到,通过在此中使用界面来删除所有的proxyFactory依赖关系 邮政。因此,您需要指定在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="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=MYDB;Integrated Security=true</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>
我已经添加了 NHibernate.ByteCode.Castle.dll
. 。当我使用MBUNIT运行测试时,我会发现我的部署文件夹应包含的错误 NHibernate.ByteCode.Castle.dll
或者 NHibernate.ByteCode.LinFu.dll
. 。我想这是正确的配置,应该可以工作。但是它不起作用。我花了很多时间在这方面。
PS:当我戴上NHIBERNATE时,未建立NHIBERNATE.BYTECODE.CASTLE项目。我将项目添加到解决方案中并构建。然后我引用了组件。
解决方案
不久前,我也有同样的情况。
当您说添加参考时,是实际项目还是测试项目?它应该在两者中。另外,确保在参考的属性(F4)中设置为“ local”。
我采用的另一种方法是检查DLL是否在应用程序运行的目录中,请在任何配置之前调用以下方式。
Console.WriteLine(Directory.GetCurrentDirectory());
在我的情况下,我了解到,当使用Resharper执行测试时,它在与我预期的不同位置运行,并且没有包含DLL。做一个干净的解决方案和重建似乎可以纠正问题。
希望这能为您提供几件事。
不隶属于 StackOverflow