I am using VS2010, C # 4.0, NHibernate, and NUnit in the project I'm working on. When running database tests, I ran into a more complex problem. When I run my tests, nunit-agent.exe crashes for no apparent reason. I have since discovered that when I debug my tests, I get the following exception in the TestFixtureSetup method:
TypeInitializationException: type initializer for 'NHibernate.ByteCode.Castle.ProxyFactory' threw an exception. Could not load file or assembly "Castle.DynamicProxy2, Version = 2.1.0.0, Culture = neutral, PublicKeyToken = 407dd0808d44fbdc 'or one of its dependencies. The located assembly manifest definitions do not match the assembly reference position. (Exception from HRESULT: 0x80131040): "Castle.DynamicProxy2, Version = 2.1.0.0, Culture = Neutral, PublicKeyToken = 407dd0808d44fbdc
Now it seems to me that what he is looking for is identical to the one that he found?
I double checked and the assembly is referenced in a test project. I also tried to read the link, but to no avail .. Any ideas?
UPDATE2: I tried changing the target structure to .net 3.5 of all my projects, and now all the tests fail with the error above.
UPDATE: Some tests work, others do not. I have a client class:
public class Customer : IEntity<string>
{
private readonly string id;
public virtual string Id
{
get { return id; }
}
public virtual string Name { get; set; }
public virtual Address Address { get; set; }
}
Where the tests go perfectly. However, tests for my product class:
public class Product : IEntity<string>
{
private readonly string id;
public virtual string Name { get; set; }
public virtual decimal Price { get; set; }
public virtual string Id
{
get { return Id; }
}
}
Doesn't work (I get an exception before). And the funny thing is that the tests for both classes use the same base class that contains all the database access code.