简体   繁体   中英

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.

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. 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.

The problem in Visual Studio 2012 itself. To run tests by default it doesn't use your bin folder, it deploys assemblies to system folder.

So, your app.config doesn't work in this case. There are several solutions like copy your app.config to this folder on post build event or use .runsettings File. But the simplest way is to update your Visual Studio.

This issue was fixed in Visual Studio 2012 Update 4 and Visual Studio 2013.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM