简体   繁体   中英

VS2010 + NUnit failing to load assemblies?

Im using VS2010, C# 4.0, NHibernate and NUnit in a project Im working on.. In doing database tests I've come across a wierd problem.. When I run my tests, nunit-agent.exe crashes for no apparent reason.. I've since then discovered that when i debug my tests, I get the following exception in the TestFixtureSetup method:

TypeInitializationException: The 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's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc

Now, it seems to me that what it's looking for is identical to the one it found?

I've doublechecked and the assembly is referenced in the test project.. I have also tried readding the reference, but to no avail.. Any ideas?

UPDATE2: I tried changing the target framework to .net 3.5 of all my projects and now all tests fail with the error above..

UPDATE: Some tests works, others dont.. I have a customer 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 runs perfectly fine.. 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; }
  }
}

Does not work (I get the exception from before).. And the funny thing is that tests for both classes uses the exact same base class that contains all the database access code..

我解决了问题..看来Nhibernate正在寻找DynamicProxy 2.1.0,而我引用了2.1.1 ..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM