x86 unit testing

I expect this is a pretty obscure problem that not many of you will run into, but here it is if only so that I can remember it next time. We have some code that has to run x86, even on x64 platforms, so our assemblies are marked as x86. This extends to the unit tests otherwise they wont run. Unfortunately, when the unit test runner runs them, it fails with BadImageFormatException.

The solution is to use corflags.exe to force Jetbrains.Resharper.TaskRunner.exe to run in x86 mode:

coreflags /32BIT+ Jetbrains.Resharper.TaskRunner.exe

Of course, this will now run all tests as x86, even on x64 platforms, which may not be what you want.

1 comment
Comment actions Permalink

What is the scope of that command?  Forevermore?  Until a reboot?

Also, is there any possibilty of R# determining the mode from the Solution Platforms drop-down (Visual Studio toolbar, generally next to the Debug/Release selector)?  When I set x86 mode for the entire solution, TaskRunner fails to run, but does work if it's set to "Any CPU" ... assuming the underlying code works in 64bit.  The TaskRunner error is simply "build failed" although the VS build is successful.

Setting at the project level generally works, but at the moment we have waaaaaay too many projects to configure all of them individually (yes, we're overworked), but shouldn't R# handle setting it at the solution level as well?

0

Please sign in to leave a comment.