24. April 2013 06:30 by Rick Glos
I’ve got a bunch of unit tests that were in an existing VS2010 project that worked great. They had an AssemblyInitialize method that dropped and recreated the database and used Microsoft.SqlServer.Smo to run scripts.
When I upgraded this solution to VS2012 the unit tests would no longer execute and I was receiving the following error:
System.IO.FileLoadException: Mixed mode assembly is built against version ‘v2.0.50727’ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.. Aborting test execution.
I can’t very well change how Microsoft.SqlServer.Smo is compiled.
Googling around I didn’t find much but eventually ran across a comment buried in StackOverflow question about hand editing the VS2012 test runner.
The solution is to open the config file at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.executionengine.x86.exe.config and add the following:
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0"/></startup>
Note that I had to restart VS2012 to unload the exe and reload it. You can see it running as a child process of VS2012 in Process Explorer.
Hope that helps someone else.