【问题标题】:how to refresh/reload app.config file before a function or method executes如何在函数或方法执行之前刷新/重新加载 app.config 文件
【发布时间】:2014-05-01 08:11:14
【问题描述】:

我有一个 Windows 服务,可以在特定日期的特定时间发送电子邮件。发送电子邮件的时间和时间以及要使用的 SMTP 服务器等信息都存储在 app.config 文件中。

当我在记事本中打开 app.config 文件并更改这些值时,即使我调用 ConfigurationManager.RefreshSection("configuration");,我的服务也不会选择更改

我如何确保每次执行我的电子邮件发送功能时,它必须首先查询 app.config 以获取最新的更改/值。我必须先重启服务吗?

【问题讨论】:

    标签: c# windows-services app-config configuration-files configurationmanager


    【解决方案1】:

    不要修改 app.config,而是尝试使用此刷新部分修改 appname.exe.config 文件。

    请参阅this。希望能帮助到你。谢谢

    【讨论】:

      猜你喜欢
      • 2013-03-29
      • 2012-03-07
      • 2021-06-23
      • 2012-12-17
      • 1970-01-01
      • 2017-04-12
      • 2012-07-31
      • 1970-01-01
      • 2019-12-28
      相关资源
      最近更新 更多