views:

514

answers:

1

I've read in this post that all the ProxyFactory dependency was removed by using an interface in this post. So you need to specify which implementation to use in the hibernate.cfg.xml file. I've this configuration:

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

I've added a refernce to the NHibernate.ByteCode.Castle.dll. When I run the test using MBunit, I get the error that my deployment folder should contain either NHibernate.ByteCode.Castle.dll or NHibernate.ByteCode.LinFu.dll. I guess this is right configuration and it should work. But it is not working. I've spent much time behind this.

P.S: When I donwloaded NHibernate, the NHibernate.ByteCode.Castle project was not built. I added the project to the solution and built it. Then I referenced the assembly.

+2  A: 

I had this same situation not too long ago.

When you say you added a reference, was it to the actual project or test project? It should be within both. Also, ensure "Copy Local" is set to true in the properties(F4) of the reference.

Another approach I took to check that if dll is within the directory that the application is running from was by calling the following prior to any of the Configuration.

Console.WriteLine(Directory.GetCurrentDirectory());

In my situation, I learned that when using ReSharper to execute tests, it was running in a location different than I had expected and was not containing the dll. Doing a Clean Solution and rebuilding seemed to correct the issue.

Hope this gives you a couple of things to check.

statenjason