如何找到活动 app.config 文件的路径? [英] How to find path of active app.config file?
本文介绍了如何找到活动 app.config 文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试完成这个异常处理程序:
I'm trying to finish this exception handler:
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 时.
This problem seems to only happen to me when I'm using nUnit.
推荐答案
试试这个
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
这篇关于如何找到活动 app.config 文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文