.NetCore单元测试项目无法读取app.config文件

1.Console控制台程序没有问题

2.单元测试不可以,读取到的值是NULL

MSTest is running as testhost.dll, which means that ConfigurationManager is reading settings from testhost.dll.config when executing under .NET core. <br>It will look for testhost.dll.config where the testhost.dll is located as the accepted answer states. <br>What is not mentioned is that it will also look for testhost.dll.config in the location where you have your test dlls.

      1. 在单元测试工程中将app.config文件改为:testhost.dll.config

      2. 修改单元测试工程文件,配置编译后事件,动态copy生成testhost.dll.config

posted @ 2019-10-24 16:25  大侠的哥哥是菜鸟  阅读(810)  评论(0编辑  收藏  举报