c# - NUnit DLL 版本不匹配

标签 c# .net nunit spring.net

我遇到了这个奇怪的版本不匹配错误。我所有的 NUnit 测试项目过去都使用 NUnit 2.5.7,但现在我将它们切换为使用 NUnit v2.5.10,我不断收到以下错误:

FileLoadException: Could not load file or assembly 'nunit.framework, version 2.5.7...

注意:我清理、重建、仔细检查了引用,没有问题。

使用 Assembly Binder 日志查看器(见下文),在我看来,此错误的触发器是 Spring.Testing.NUnit.dll... 考虑到 Spring.Testing.Nunit 1.3.2 Nuget page,这似乎很奇怪在其依赖列表中说:NUnit (≥ 2.5.7)

知道我在这里缺少什么吗? 提前致谢,

肺结核。

Assembly Binder Log Entry (02.07.2012 @ 16:06:35)

The operation failed. Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable F:\robin\4-Development\Workspace\3rdParty\NUnit\2.5.10\nunit-agent.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: User = Mth\tbourguignon LOG: DisplayName = nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 (Fully-specified) LOG: Appbase = file:///F:/robin/4-Development/Workspace/Application LOG: Initial PrivatePath = Rh.Robin.Common.Tests\bin\Debug;Rh.Robin.Service.Test\bin\Debug;Rh.Robin.Domain.Unit.Test\bin\Debug;Rh.Robin.Service.Unit.Test\bin\Debug;Rh.Robin.Web.UI.MVC.Unit.Test\bin\Debug LOG: Dynamic Base = NULL LOG: Cache Base = C:\Users\tbourguignon.Mth\AppData\Local\Temp\nunit20\ShadowCopyCache\4980_634768419945070499 LOG: AppName = Tests_29030132 Calling assembly : Spring.Testing.NUnit, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07. === LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///F:/robin/4-Development/Workspace/Application/nunit.framework.DLL. LOG: Attempting download of new URL file:///F:/robin/4-Development/Workspace/Application/nunit.framework/nunit.framework.DLL. LOG: Attempting download of new URL file:///F:/robin/4-Development/Workspace/Application/Rh.Robin.Common.Tests/bin/Debug/nunit.framework.DLL. LOG: Assembly download was successful. Attempting setup of file: F:\robin\4-Development\Workspace\Application\Rh.Robin.Common.Tests\bin\Debug\nunit.framework.dll LOG: Entering download cache setup phase. LOG: Assembly Name is: nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 WRN: Comparing the assembly name resulted in the mismatch: Revision Number ERR: The assembly reference did not match the assembly definition found. ERR: Setup failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

最佳答案

您是否从引用更新的 NUnit 点版本中获得了什么?如果没有,您可以做的最简单的事情就是返回并引用与 Spring 在您的代码中引用的版本匹配的旧版本的 NUnit 程序集。

另一种选择是修改您的(Spring)应用程序的配置以使用binding redirects。选择较新版本的 NUnit 程序集。

这让我想知道 Spring 对 NUnit 程序集的引用是否将 Specific Version 设置为 true。不过似乎不太可能。这是有关 .NET 如何使用的引用 locates and binds assemblies at runtime .

关于c# - NUnit DLL 版本不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11295967/

相关文章:

.net - 运行Stanford.NLP.CoreNLP示例时出现TypeInitializationException

c# - 在 .NET 对象上设置 "nullable"属性

可共享页面中的 .NET JIT 程序集

c# - 单元测试时如何删除对 3rd 方代码的依赖?

c# - EmptyResult 上的 jQuery AJAX 请求炸弹

c# - 如何解决错误CS1525无效表达词 '='?

c# - 为什么我的 OpenGL ES 应用程序在 glDrawElements 上崩溃?

c# - 热巧克力认证连接用户

nunit - 使用 NAnt 中的 nunit2 任务发现

f# - 为什么我不能在 F# 中使用最新版本的 NUnit 和 FsCheck?