2009-11-07 41 views
4

我使用了一些来自夏普架构测试库,这使得使用NUnit 2.5.0的,而我的项目的其余部分使用NUnit的2.5.1所以我把组装重定向在我的测试项目中的应用程序配置文件:问题重定向NUnit的程序集版本(什么是[的AssemblyName] .temp.config?)

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <runtime> 
     <assemblyBinding> 
      <dependentAssembly> 
       <assemblyIdentity name="nunit.framework" 
            publicKeyToken="96d09a1eb7f44a77" /> 
       <bindingRedirect oldVersion="2.5.0.9122" 
           newVersion="2.5.1.9189"/> 
      </dependentAssembly>   
     </assemblyBinding> 
    </runtime> 
</configuration> 

我仍然得到一个装配重定向版本:

TestCase '' 
failed: Could not load file or assembly 'nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 
    System.IO.FileLoadException: Could not load file or assembly 'nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 
    File name: 'nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' 

启用我的融合错误日志我看到这一点:

=== Pre-bind state information === 
LOG: DisplayName = nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 
(Fully-specified) 
LOG: Appbase = file:///C:/code/Samples/PersistencePatterns/app/PersistencePatterns.Tests/bin/Debug 
LOG: Initial PrivatePath = NULL 
Calling assembly : SharpArch.Testing.NUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b5f559ae0ac4e006. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\code\Samples\PersistencePatterns\app\PersistencePatterns.Tests\bin\Debug\PersistencePatterns.Tests.dll.temp.config 
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. 
LOG: Post-policy reference: nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 
LOG: Attempting download of new URL file:///C:/code/Samples/PersistencePatterns/app/PersistencePatterns.Tests/bin/Debug/nunit.framework.DLL. 
WRN: Comparing the assembly name resulted in the mismatch: Revision Number 
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. 

什么给?它寻找的这个temp.config文件是什么?为什么它不在我的实际配置中查找?

那么不管,我增加了以下我后期生成事件:

copy $(ProjectDir)App.config $(TargetDir)\$(TargetFileName).temp.config 

一切都被复制很好,但只要我跑测试与Testdriven.NET文件消失。

任何人都可以给我一个线索,知道怎么回事?

回答

1

你有没有尝试复制类库的App.config没有“.temp”部分?

copy $(ProjectDir)App.config $(TargetDir)\$(TargetFileName).config 

编辑:的 “* .temp.config” 似乎是由TestDriven.NET产生,为[stated in the release notes of version 2.3][1]

+0

这就是Visual Studio中做了。我已经验证过,由于某种原因,通过检查文件是否存在,此功能不会中断。尽管如此,我从来没有见过这样的临时扩展。 – 2009-11-18 17:49:21

+0

你说得对,我确信它只会为可执行文件而不是类库执行此操作。我的错。正如2.3版本的发行说明(http://www.testdriven.net/downloads/ReleaseNotes.html)所述,“* .temp.config”似乎是由TestDriven.NET生成的。 – 2009-11-18 18:05:53