简体   繁体   English

VS2010 + NUnit无法加载程序集?

[英]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: 我在一个项目中使用VS2010,C#4.0,NHibernate和NUnit正在进行中..在进行数据库测试时,我遇到了一个奇怪的问题。当我运行我的测试时,nunit-agent.exe崩溃没有明显的原因..我从那以后发现,当我调试我的测试时,我在TestFixtureSetup方法中得到以下异常:

TypeInitializationException: The type initializer for 'NHibernate.ByteCode.Castle.ProxyFactory' threw an exception. TypeInitializationException:'NHibernate.ByteCode.Castle.ProxyFactory'的类型初始值设定项引发了异常。 Could not load file or assembly 'Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. 无法加载文件或程序集'Castle.DynamicProxy2,Version = 2.1.0.0,Culture = neutral,PublicKeyToken = 407dd0808d44fbdc'或其依赖项之一。 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 (来自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.. UPDATE2:我尝试将目标框架更改为所有项目的.net 3.5,现在所有测试都失败并出现上述错误。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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