NUnit: 无法加载程序集nunit.framework。

7

尝试执行一个引用了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 Framework 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。

https://dev59.com/oXRC5IYBdhLWcg3wJNcN - Soner Gönül
1
为了详细说明@Soner Gönül发布的链接:你的目标CPU是什么(x86、x84还是任何CPU)?你当前运行在哪个CPU上? - BTownTKD
我正在针对任何 CPU 进行开发,但目前在 x86 CPU 上运行。使用任何 CPU 无法正常工作。 - Willy
你正在运行的 "nunit-x86.exe" 的路径是什么? - Greg Smith
1个回答

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

<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"的值即可。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接