简体   繁体   中英

System.BadImageFormatException while using NUnit and Resharper

I am using Visual Studio 2010 and Resharper 9.0. I have 64 bit system. I have NUnit 2.6.4

I get this when I try to run any test. No tests work here. Can anyone please tell how to solve this error.

Error:

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.

This is most likely due to your test assembly being compiled to 64 bit when your production code requires 32 bit, or vice versa. ReSharper's test runner will launch a hosting process, based on your test assembly (.net 4.0 or 4.5, 32 or 64 bit, etc.). If the project is marked as 32 bit, 64 bit, or AnyCPU, it launches the appropriate hosting application.

If your production assembly requires eg 64 bit, but your test assembly is 32 bit, the 32 bit test hosting application is launched, and that is unable to load the production assembly, and throws the BadImageFormatException .

The solution is to change the bit-ness of the test assembly to match the production assembly.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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