【问题标题】:Using app.config to determine a common config file使用 app.config 确定一个通用的配置文件
【发布时间】:2014-03-01 11:22:13
【问题描述】:

我正在使用 app.config 做一个 Windows 服务,其中有一个部分可以检索另一个文件中的通用配置。使用

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "filepath\\file"); 

对我有用,但使用

string appconfig = ConfigurationManager.AppSettings["CommonAppSetting"];
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", appconfig);

没有。它来自windows服务的app.config,而不是通用配置。

我做错了什么,或者有其他更好的方法吗?

【问题讨论】:

    标签: windows-services app-config


    【解决方案1】:

    您需要重置 ConfigurationManager 中的一些变量 (ClientConfigPaths) 以使其刷新其值。这些可以在以下接受的答案中看到(完成这项工作的代码)。

    Change default app.config at runtime

    【讨论】:

      猜你喜欢
      • 2010-11-22
      • 2010-10-09
      • 1970-01-01
      • 2010-10-04
      • 2016-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-25
      相关资源
      最近更新 更多