Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ReSharper unit test architecture to x64?

Tags:

resharper

In VS2012, I resolved a BadImageException from running a unit test by going to: TEST-> TEST SETTINGS -> DEFAULT PROCESSOR ARCHITECTURE -> x64.

This works in the built in Visual Studio test window but I cannot find the equivalent settings for ReSharper and so I cannot run the unit tests by clicking on the little nodes to left of the test. This is obviously not critical but really annoying.

Does anyone know where these settings are?

like image 207
R Swasey Avatar asked Oct 01 '13 20:10

R Swasey


3 Answers

ReSharper will run tests with the bit-ness of the test project. So if your test project is AnyCpu, it will run in an AnyCpu host process, which means 32bit on a 32bit system or 64bit on a 64bit system. If you set your project to be 32bit or 64bit specific, ReSharper will run it in a 32bit or 64bit host process.

So, if your production code is 32 bit specific, you should make your test project 32 bit specific, too. If your production code is 64 bit specific, it should work fine, as long as your test project is 64 bit or AnyCpu.

Similarly, it will use the .net runtime of the test project - .net 2 or .net 4.

These defaults work for the vast majority of cases. I've never had to set it manually, but you can override this behaviour, and force a bit-ness or .net framework version. ReSharper 8 has these settings in the Options dialog (Options -> Tools -> Unit Testing). If you set this when a solution is open, it sets it for the current solution. If there isn't a solution open, it becomes the default for all solutions. You can also set this on a per-test run basis in the unit test sessions window. This setting doesn't persist.

like image 91
citizenmatt Avatar answered Nov 18 '22 23:11

citizenmatt


I tried different things that I found in Google and on StackOverflow (including other answers in this topic), but what worked for me is:

ReSharper's Unit Test Sessions window -> on the top panel set Platform dropdown to 64-bit.

enter image description here

like image 9
nightcoder Avatar answered Nov 18 '22 23:11

nightcoder


My solution is too hacky, but thats the only thing which worked for me

I placed a copy of vstest.executionengine.x86.exe for backup and placed a renamed vstest.executionengine.exe (64bit version) instead of old 32 bit version.

like image 3
Valentin Kuzub Avatar answered Nov 19 '22 01:11

Valentin Kuzub