4

我正在使用 Sharp Architecture 的一些测试库,它们使用 NUnit 2.5.0,而我的项目的其余部分使用 NUnit 2.5.1,所以我在我的测试项目应用程序配置文件中放置了一个程序集重定向:

<?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 运行测试,文件就会消失。

谁能给我一个关于发生了什么的线索?

4

1 回答 1

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]

于 2009-11-17T21:33:21.020 回答