[英]visual studio 2012 test project is loading configuration settings from machine.config but not from app.config
I am trapped in to a misterious issue. 我陷入了一个棘手的问题。 The visual studio 2012 test project, whenever I am tring to run it, is loading configuration settings from machine.config but not from app.config.
每当我尝试运行Visual Studio 2012测试项目时,它都会从machine.config中加载配置设置,而不是从app.config中加载配置设置。
What you are describing here is normal. 您在这里描述的是正常现象。 The reason for this the test runner is an external application that is ran by visual studio when you run the tests.
这样做的原因是测试运行程序是运行测试时Visual Studio运行的外部应用程序。 As such, the test runner has its own config file that you would have to modify to pull this off.
因此,测试运行器具有其自己的配置文件,您必须对其进行修改以实现此目的。 Conversely, the machine.config applies to every .net process that runs on your machine, so those settings will come in to the test project.
相反,machine.config适用于计算机上运行的每个.net进程,因此这些设置将进入测试项目。
The problem in Visual Studio 2012 itself. Visual Studio 2012本身的问题。 To run tests by default it doesn't use your bin folder, it deploys assemblies to system folder.
要默认运行测试,它不使用您的bin文件夹,而是将程序集部署到系统文件夹。
So, your app.config doesn't work in this case. 因此,您的app.config在这种情况下不起作用。 There are several solutions like copy your
app.config
to this folder on post build event or use .runsettings File. 有几种解决方案,例如在构建后事件中将
app.config
复制到此文件夹或使用.runsettings文件。 But the simplest way is to update your Visual Studio. 但是最简单的方法是更新Visual Studio。
This issue was fixed in Visual Studio 2012 Update 4 and Visual Studio 2013. 此问题已在Visual Studio 2012 Update 4和Visual Studio 2013中修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.