【问题标题】:Overriding the AppSettings覆盖 AppSettings
【发布时间】:2013-06-16 21:05:49
【问题描述】:

我的 App.config 中有这样的代码 sn-p -

<appSettings file="..\..\..\master_AppSettings.config"> 
<add key="ApplicationDSN" value="XYZConnectionString" />
</appSettings>

在 master_AppSettings.config 文件中,我将“ApplicationDSN”设置为“ABCConnectionString”。现在我想要的是以下行为 - 如果 App.config 中没有再次设置“ApplicationDSN”,则从 master_AppSettings.config 文件中获取值,否则从 App.config 中获取值。基本上,如果 App.config 中存在该值,我想覆盖它。

问题是上述方案似乎不起作用。 C# 项目仅从 master_AppSettings.config 中获取值,如果在 App.config 中提及,则忽略。

那么,我怎样才能实施我的方案才能工作? 任何帮助将不胜感激。

谢谢, 毗婆娑

【问题讨论】:

    标签: c# app-config


    【解决方案1】:

    没有办法。因为它是另一种方式。在 App.config 中提及您的所有基本设置 - 无论您想覆盖什么,都将其放在外部设置文件中。外部文件覆盖 App.config。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-18
      • 2016-11-06
      • 2012-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多