繁体   English   中英

使用 NUnit 和 Resharper 时出现 System.BadImageFormatException

[英]System.BadImageFormatException while using NUnit and Resharper

我正在使用 Visual Studio 2010 和 Resharper 9.0。 我有64位系统。 我有 NUnit 2.6.4

当我尝试运行任何测试时,我会得到这个。 这里没有测试工作。 谁能告诉我如何解决这个错误。

错误:

System.BadImageFormatException : Could not load file or assembly 'NUnitFirst, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

这很可能是因为当您的生产代码需要 32 位时,您的测试程序集被编译为 64 位,反之亦然。 ReSharper 的测试运行器将根据您的测试程序集(.net 4.0 或 4.5、32 或 64 位等)启动托管进程。 如果项目被标记为 32 位、64 位或 AnyCPU,它会启动相应的托管应用程序。

如果您的生产程序集需要例如 64 位,但您的测试程序集是 32 位,则启动 32 位测试托管应用程序,并且无法加载生产程序集,并抛出BadImageFormatException

解决方案是更改测试组件的位数以匹配生产组件。

如果你编译为 x64 位使用nunit.exe否则使用nunit-x86.exe

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM