.net – MSTest: running unit tests in 64 bit mode

netunit testingvisual studio 2010visual studio 2012

I can successfully run tests inside VS2012 in 64 bit mode using the following settings:

Run tests in 64-bit

But I still cannot do it on the build server. The error I get is:

Unable to load the test container '…\Tests\UnitTesting\bin\Release\UnitTesting.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///…\Tests\UnitTesting\bin\Release\UnitTesting.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I compiled the UnitTesting DLL as AnyCPU and added the following line to the Local.TestSettings file:

<Execution hostProcessPlatform="MSIL">

What else should I check?

Thanks.

Best Answer

I still had a referenced DLL in my Visual Studio project compiled in x64 instead of AnyCPU. After changing it tests now run everywhere.