2009-07-21 67 views
0

我读过这篇文章,通过在这个post中使用接口删除了所有的ProxyFactory依赖项。 所以你需要指定在hibernate.cfg.xml文件中使用哪个实现。 我有这个配置:NHibernate 2.1.0有什么问题?我总是得到一个错误!

<?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> 

我添加了一个refernce到NHibernate.ByteCode.Castle.dll。当我使用MBunit运行测试时,出现部署文件夹应包含NHibernate.ByteCode.Castle.dllNHibernate.ByteCode.LinFu.dll的错误。我想这是正确的配置,它应该工作。但它不起作用。我花了很多时间在这方面。

P.S:当我donwloaded NHibernate,NHibernate.ByteCode.Castle项目没有建立。我将该项目添加到解决方案并构建它。然后我引用了这个程序集。

回答

2

不久前我也有过这种情况。

当你说你添加了一个参考,是否是实际的项目或测试项目?它应该在两者之内。此外,请确保参考的属性(F4)中的“复制本地”设置为true。

我用来检查dll是否位于应用程序运行目录中的另一种方法是在任何配置之前调用以下命令。

Console.WriteLine(Directory.GetCurrentDirectory()); 

在我的情况,我了解到,使用ReSharper的执行测试时,它在不同的比我预想的位置上运行,并没有包含该DLL。做一个清洁的解决方案和重建似乎纠正了这个问题。

希望这给你一些事情来检查。

相关问题