【发布时间】:2016-01-11 03:35:23
【问题描述】:
我想从名为secrets.config 的外部配置文件中读取我的控制台应用程序的appSettings 的一部分,而我想从app.config 中读取其余部分。
目前,我已经设置好了,但它似乎没有从 secrets.config 读取,甚至没有告诉我读取失败。
在我的 app.config 中
<appSettings file = "secrets.config">
<add key = "Foo" value = "Bar" />
</appSettings>
在 secrets.config 中,与 app.config 位于同一文件夹中
<appSettings>
<add key = "Secret" value = "Tiger" />
</appSettings>
在我的代码中
var secret = ConfigurationManager.AppSettings["Secret"];
// secret turns out to be null
【问题讨论】:
-
嗯,抱歉,刚刚意识到您已经采用了该 Q 的答案中详述的方法之一。
标签: c# .net configuration configuration-files configurationmanager