Topics: ReSharper test runner
Mar 18, 2012 at 10:19 AM

When I run xunit tests under x64, I get BadImageException. According to this commit ( I need somehow specify I need to use .NET 4 test runner. But how can I do it?

Mar 23, 2012 at 7:47 AM

For the resharper runner, you don't need to do anything. Resharper will pick the appropriate host for your tests. If you're just talking plain old xunit, console or gui, just make sure you're running the appropriate .exe - there's one for each combination of .net 2/4 + x86/x64.

Mar 23, 2012 at 11:08 AM

But I have described above problem with Resharper 6.1 runner...

Mar 24, 2012 at 11:09 PM

OK. Is your test assembly set as x86, x64 or AnyCpu? What about *all* of the assemblies it references, directly or indirectly?

If I remember rightly, AnyCpu on x64 will launch as 64 bit, but if you're then referencing an assembly that is set to x86, it won't be able to load this 32 bit dll into the 64 bit process, and will blow up with the BadImageException.

Are you able to share the project? You can email it to me if you like.

Sep 22, 2012 at 7:03 AM

Was there any follow up to this request? I have just run into this problem as well. My test project depends on an assembly with x86 set. Is there any way to force the runner to be x86? Thanks.

Sep 24, 2012 at 8:39 AM

As far as I am aware, there is no problem here. ReSharper will run your test assembly in an executable with the appropriate bit-ness. In your case, your test assembly depends on an assembly that requires x86, so make sure your test assembly is set to x86. If it is set to AnyCPU, it will run as x64 on a 64 bit system, and you are much more likely to get a BadImageException.