我想从名为secrets.config
的外部配置文件中读取我的控制台应用程序的appSettings
的一部分,而其余部分我希望从app.config
。从外部配置文件中读取appSettings的一部分
目前,我有这个设置,但它似乎不是从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
的可能的复制[ConfigurationManager.AppSettings使用其他配置文件(http://stackoverflow.com/questions/16425407/configurationmanager-appsettings -use-another-config-file) –
恩,对不起,刚才意识到你已经采取了Q.答案中详述的方法之一。 –