的Visual Studio 2012测试项目的混合模式运行 [英] Visual Studio 2012 Test Project Mixed Mode Runtime
问题描述
我目前正在在Visual Studio 2012 RC与测试项目。我已经包括以下组件:
- Microsoft.SqlServer.Smo
- Microsoft.SqlServer.SmoExtend
- Microsoft.SqlServer.ConnectionInfo
- Microsoft.SqlServer.Management.Sdk.Sfc
这些组件是构建2.0.50727版本,我已经在.NET 4.0中的测试项目。因此,基于这一信息,我添加了一个app.config文件到项目具有以下行:
< XML版本=1.0编码=UTF-8&GT?;
<结构>
<启动useLegacyV2RuntimeActivationPolicy =真正的>
< supportedRuntime版本=V4.0/>
< /启动>
< /结构>
当我要去我收到所有的时间来运行此以下消息:
混合模式组件构建针对运行时的版本V2.0.50727',不能在4.0运行时无需附加配置信息加载。
这是一个的Visual Studio 2012 RC测试项目,它忽略了一个虫虫危机app.config文件还是我做一些完全错误的?
有关更多的信息我已经包含了也是我的测试code:
VAR的connectionString =新SqlConnectionStringBuilder()
{
数据源= @(本地),
IntegratedSecurity =真
} .ConnectionString;
VAR SQL =ALTER DATABASE [测试]集SINGLE_USER与回滚立即去;
SQL + =DROP DATABASE [测试]去;
SQL + =创建数据库[测试]去;
SQL + = Properties.Resources.Test;
VAR连接=新的SqlConnection(的connectionString);
VAR服务器=新服务器(新ServerConnection(连接));
server.ConnectionContext.ExecuteNonQuery(SQL);
这似乎是固定在Visual Studio 2012,当它来到RTM。不需要更新配置文件
我测试过,在的Visual Studio 2012更新4和Visual Studio 2013更新1 RC和你的code完美的作品与上面提到的code和汇编引用和没有更新的测试运行的配置文件。这有可能是在一个测试断裂或松开的Visual Studio 2012的候补,但如果是,它似乎已经被修正。
正如汉斯提到您可以更新的.config
文件的 vstest.executionengine.x86.exe.config
,但对于改变的您计算机上的所有的测试项目,需要应用到你的项目工作(和生成服务器上,你应该使用一个)所有的人的行为。 这应该是最后的手段!!
I'm currently working in the Visual Studio 2012 RC with a test project. I have included the following assemblies:
- Microsoft.SqlServer.Smo
- Microsoft.SqlServer.SmoExtend
- Microsoft.SqlServer.ConnectionInfo
- Microsoft.SqlServer.Management.Sdk.Sfc
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);
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!!
这篇关于的Visual Studio 2012测试项目的混合模式运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!