【问题标题】:ConfigurationManager doesn't save settings to exe.configConfigurationManager 不会将设置保存到 exe.config
【发布时间】:2012-01-21 02:08:46
【问题描述】:

(我的问题与this one类似,但代码略有不同,解决方案对我不起作用)

我正在尝试将设置更改保存到app.config

Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
config.AppSettings.Settings("HistoryRootDirectoryPath").Value = p_historySavingPath
config.Save(ConfigurationSaveMode.Modified)
ConfigurationManager.RefreshSection("appSettings")

任何内容都不会保存到 bin 文件夹中的 exe.config 文件中,也不会保存到实际的 app.config 文件中。我做错了什么?

【问题讨论】:

  • 您是否遇到任何错误?例外?您是否同时查看了 DebugRelease 文件夹?
  • @Oded:检查了调试和发布,没有抛出异常。
  • 我发现它保存在“**.vshost.exe.config”中
  • 啊。因为代码是在 Visual Studio 进程宿主下运行的。

标签: .net vb.net .net-4.0 configuration app-config


【解决方案1】:

终于发现更改保存在.vshost.exe.config下。

正如Oded 提到的,那是因为代码是在Visual Studio 进程宿主下运行的。

请注意,一旦您停止进程运行,更改就会被还原。

【讨论】:

    猜你喜欢
    • 2011-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-17
    • 2013-12-22
    • 1970-01-01
    相关资源
    最近更新 更多