gpt4 book ai didi

.net - 重定向 NUnit 程序集版本时出现问题(什么是 [AssemblyName].temp.config?)

转载 作者:行者123 更新时间:2023-12-02 13:20:56 25 4
gpt4 key购买 nike

我正在使用 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 运行测试,文件就会消失。

谁能告诉我发生了什么事吗?

最佳答案

您是否尝试过复制类库的 App.config 而不包含“.temp”部分?

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

编辑:“*.temp.config”似乎是由 TestDriven.NET 生成的,如 [版本 2.3 的发行说明中所述][1]

关于.net - 重定向 NUnit 程序集版本时出现问题(什么是 [AssemblyName].temp.config?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1694806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com