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
When working with high memory code you may find you need to alter the R# test runner config to include
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
You can find this file located at
%localappdata%\JetBrains\Installations\ReSharperPlatformVs12\
JetBrains.ReSharper.TaskRunner.CLR45.x64.exe.config
This path is likely dependudant upon Visual Studio version and may vary upon R# version. This specific path is Visual Studio 2013 with Resharper 9.1. Recurrent issue with Resharper 10. Location of config file is unchanged. https://youtrack.jetbrains.com/issue/RSRP-446178
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.
With, Visual Studio 2015, I've found that both x86 and x64 settings will cause this. The solution was to close and restart Visual Studio.
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.
I just ran into this with ReSharper and MsTests - error "unit test runner failed to run tests incompatible target platform".
Our issue was that the test project wasn't being built.
To fix:
Build
Configuration Manager
Confirm that Build is ticked.
Switch between your Solution Configurations to confirm it's being built in all configurations.
We had a similar issue when trying to setup MSTEST for Sharepoint 2007 - it would keep running in x86 instead of x64. Instantiating SPSite
kept saying "The Web application at http://server:port/ could not be found".
I started with replacing the EXEs suggested by @valentin-kuzub to confirm it would work - but then realized that we had the wrong Test Settings file active - there were (2) Local.testsettings
and TraceAndTestImpact.testsettings
. One of them was set to use x86 instead of targeting x64.
Another option is switching from testSettings to runSettings and assigning TargetPlatform.
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<!-- [x86] | x64 - You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x64</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
The last option (which you already tried) is in the XML comments from option #2 -> You can also change it from menu Test->Test Settings->Default Processor Architecture->x64.