我正在使用Sharp Architecture的一些测试库,它们使用NUnit 2.5.0,而我的项目的其余部分使用NUnit 2.5.1,所以我在我的测试项目app配置文件中放置了一个程序集重定向:
<?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'
启用我的Fusion ErrorLog我看到了:
=== 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运行测试,文件就会消失。
有人能给我一些线索吗?
答案 0 :(得分:1)
您是否尝试过复制没有“.temp”部分的类库的App.config?
copy $(ProjectDir)App.config $(TargetDir)\$(TargetFileName).config
编辑:“* .temp.config”似乎是由TestDriven.NET生成的,[stated in the release notes of version 2.3][1]