我正在尝试完成这个异常处理程序:
if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null)
{
string pathOfActiveConfigFile = ...?
throw new ConfigurationErrorsException(
"You either forgot to set the connection string, or " +
"you're using a unit test framework that looks for "+
"the config file in strange places, update this file : "
+ pathOfActiveConfigFile);
}
这个问题似乎只发生在我使用 nUnit 时。
对于.Net框架,试试这个
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
对于 .Net core 或任何更新的内容,请参阅其他答案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)