【问题标题】:NUnit: Could not load assembly nunit.frameworkNUnit:无法加载程序集 nunit.framework
【发布时间】:2012-12-29 12:25:19
【问题描述】:

尝试执行引用 nunit.framework 的单元测试失败:

System.IO.FileNotFoundException: Could not load file or assembly
'nunit.framework, Version=2.5.10.11092, Culture=neutral,
PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The
system cannot find the file specified.

我的情况如下:
Visual Studio 2010 TFS
C# 和 .NET Framewok v4.0
NUnit 2.6.0.12051

详细解释:
我有一个引用一些 dll 的测试项目,一个是 nunit.framework.dll。 此 dll (nunit.framework.dll) 指向安装 nunit 2.6.0.12051 的文件夹。 我通过 nunit-x86.exe 执行 NUnit(不是来自 Visual Studio),一旦启动,我就会加载测试项目(它是一个类库,dll)。 Nunit 尝试加载,但出现上述错误。测试项目编译 好的,dll 生成正确。测试项目也针对 .NET Framework v4.0。

【问题讨论】:

  • 详细说明@Soner Gönül 发布的链接:您的目标是什么 CPU(x86、x84 或任何 CPU)?您目前在哪个 CPU 上运行?
  • 我的目标是任何 CPU,我目前在 x86 cpu 上运行。使用任何 CPU 都不起作用。
  • 您正在运行的“nunit-x86.exe”的路径是什么?

标签: c# .net visual-studio-2010 nunit


【解决方案1】:

请尝试重定向配置文件中的程序集绑定:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-2.6.0.12051" newVersion="2.6.0.12051"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

您可能已经有上述记录。在这种情况下,只需调整“newVersion”值即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多