I get the following error when I manually run my unit test project from the command line using VSTest.Console, or when I run it as a build step from teamcity (also using vstest):
Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime
Some googling shows that this is likely cause by the fact that the unit test project references another project that uses 'SMO' for dropping and creating a database.
The unit tests run fine when I run them from within visual studio. The error only occurs when I run them from the command line or from TeamCity. All related questions on stackoverflow suggest that the following should be added to a config file:
However, I have no idea which configuration file. I've tried adding it to the app.config file (which I manually copied to the bin directory), but that makes no difference. The config files that are used by visual studio have the correct startup attributes (which explains why it works when I run the tests from Visual Studio)
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.executionengine.x86.exe.config (32-bit)
or
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.executionengine.exe.config (64-bit)
Please help! How should I tell VSTest to "useLegacyV2RuntimeActivationPolicy="true""?