Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper Unit Test Runner failed to run tests (System.BadImageFormatException) in release

Using VS 10.0.40219.1, Resharper 8.2.1 I had switched over to a Release build and forgotten about it. Next time I tried to run any of the unit tests, I got the error "Resharper Unit Test Runner failed to run tests" System.BadImageFormatException: Could not load file or assembly 'HearThis, Version... Eventually I figured out that I was in Release mode and switched back to Debug, where all my tests run just fine. At the moment, at least, I'm not too terribly worried about needing to run my unit tests in release mode, but it's hard to say that I'll never need to do that. The question is why is it failing. On the TeamCity build server, it successfully does a release build and and runs the tests. I know I've run tests in release mode in the past, but I just tried another project, and it also fails in the same way. Is there possibly some new bug in Resharper's Test Runner, or could something have gotten corrupted, deleted, ???

like image 680
Tom Bogle Avatar asked Aug 13 '14 19:08

Tom Bogle


1 Answers

A BadImageFormatException is usually due to a mixup with the 32/64 bit settings. Make sure your test assembly has the same bit-ness as your assemblies being tested. For example, if you're on a 64 bit machine, and any of the assemblies require 32 bit (perhaps you're p/invoking into a 32 bit native dll), then the test assembly should also be 32 bit.

ReSharper runs tests in an external process, and supports 32/64 bit. It uses the test assembly's settings to decide which version of the external process to run.

like image 89
citizenmatt Avatar answered Sep 27 '22 19:09

citizenmatt