如何找到活动的app.config文件的路径?路径、文件、app、config

由网友(繁华落尽、勿忘初心)分享简介:我试图完成这个异常处理程序:I'm trying to finish this exception handler:if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null){string pathOfActiveConfigFile...

我试图完成这个异常处理程序:

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

希望它可以帮助

Hope it helps

阅读全文

相关推荐

最新文章