I'm currently working in the Visual Studio 2012 RC with a test project. I have included the following assemblies:
These assemblies are build in version 2.0.50727 and I have a test project in .NET 4.0. So based on this information I have added an app.config file into the project with the following lines:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
When I'm going to run this I receive all the time the following message:
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.
Is this a bug in a Visual Studio 2012 RC Test Project that it ignore's the app.config file or am I doing something completely wrong?
For additional information I have included also my test code:
var connectionString = new SqlConnectionStringBuilder()
{
DataSource = @"(local)",
IntegratedSecurity = true
}.ConnectionString;
var sql = "alter database [Test] set single_user with rollback immediate go ";
sql += "drop database [Test] go ";
sql += "create database [Test] go ";
sql += Properties.Resources.Test;
var connection = new SqlConnection(connectionString);
var server = new Server(new ServerConnection(connection));
server.ConnectionContext.ExecuteNonQuery(sql);
Select the C++ project in Solution Explorer and click the Properties icon, press Alt+Enter, or right-click and choose Properties. In the <Project> Property Pages dialog box, expand Configuration Properties, and then select Debugging. Set Debugger Type to Mixed or Auto. Select OK.
Open Visual Studio. On the start window, choose Create a new project. On the Create a new project page, type web test into the search box, and then select the Web Performance and Load Test Project [Deprecated] template for C#.
In the Visual Studio toolbar, make sure the configuration is set to Debug. To start debugging, select the profile name in the toolbar, such as <project profile name>, IIS Express, or <IIS profile name> in the toolbar, select Start Debugging from the Debug menu, or press F5.
This seems to be fixed in Visual Studio 2012 when it went RTM. No need to update config files
I've tested that in Visual Studio 2012 Update 4 and Visual Studio 2013 Update 1 RC and your code works flawlessly with the above mentioned code and assembly references and without updating the config file of the test runner. It is possible this was broken in a beta or release candidate of Visual Studio 2012, but if it was, it seems to be fixed now.
As Hans mentions you can update the .config
file for the vstest.executionengine.x86.exe.config
, but that changes the behavior for all test projects on your machine and needs to be applied to all people working on your project (and on a build server should you be using one). This should be a last resort!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With