X86/X64 platform related issues are very common when executing tests using different test runners, and NCrunch is no exception to this. Because NCrunch is also integrated with the build process, there is an extra dimension of complexity that is worth understanding when trying to troubleshoot platform related issues within the NCrunch environment.
If you notice that the output assembly built by NCrunch (in one of its workspaces) is targeting the wrong CPU architecture, be aware that this problem is likely to be caused by differences in the way that NCrunch handles the $(Configuration) and $(Platform) build properties (see project build platform and configuration).
By default, NCrunch will always build to the CPU architecture that is defined within the project file. It is possible to change the CPU architecture via NCrunch configuration through the use of the use build platform setting.
NCrunch will apply certain rules when deciding the CPU architecture that should be used within its testing environment:
MSTest relies on a global .testsettings file to specify the target platform that should be used in a test environment. NCrunch does not consider the .testsettings file. Instead, adjust the use cpu architecture setting to set the target platform for your test environment.
There is a lack of standardisation between test runners in which processor architecture should be used in a test environment. Best practice is to always set up test projects with a target build platform identical to the platform that should be used inside the test environment. In this way, it should be very easy to understand which platform will be used for the test environment, as the output assembly won't support anything else.
By configuring your test projects with a target platform of AnyCPU, you are effectively stating that the tests within the project and all referenced code can function without problems in both X86 and X64 environments. If you have code within the test project or referenced by the test project that does not fit this description, then do not use AnyCPU.