我想从外部配置文件中读取控制台应用程序的
appSettings
部分,例如名为secrets.config
的文件,而其余部分我想从app.config
中读取。
目前,我已经设置好了,但似乎没有从secrets.config
中读取,并且它甚至没有告诉我读取失败的原因。
在我的app.config中:<appSettings file = "secrets.config">
<add key = "Foo" value = "Bar" />
</appSettings>
在与 app.config 文件相同的文件夹中的 secrets.config 中。<appSettings>
<add key = "Secret" value = "Tiger" />
</appSettings>
在我的代码中
var secret = ConfigurationManager.AppSettings["Secret"];
// secret turns out to be null