在测试过程中发现读取App.config中的连接字符串是null
,后经反复测试,发现根本不能读取到app.conf文件。
结论: 正确,引用了最新的nuget包,引用配置如下
结论:一切正常,配置文件符合规范,样式如下
在生成目录中(例如 bin\debug)找到生成的配置文件,或者将原来的app.config拷贝过来,重命名为:testhost.dll.config
通过工程的生成后事件进行处理,命令如下
copy $(ProjectDir)App.config $(OutDir)testhost.dll.config
这样就能自动把app.config拷贝到bin\debug中,并且命名成testhost.dll.config
在此感谢网友的文章
https://www.cnblogs.com/niuge/p/11732941.html
*MSTest is running as testhost.dll, which means that ConfigurationManager is reading settings from testhost.dll.config when executing under .NET core. *
*It will look for testhost.dll.config where the testhost.dll is located as the accepted answer states. *
What is not mentioned is that it will also look for testhost.dll.config in the location where you have your test dlls.
上一篇:everything常用搜索命令
下一篇:会计制度设计名词解释大全