ConfigurationManager不会将设置保存到exe.config

Mic*_*elS 3 .net vb.net configuration app-config .net-4.0

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

我正在尝试将设置更改保存到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")
Run Code Online (Sandbox Code Playgroud)

没有任何内容既不保存exe.config在bin文件夹中的文件中,也不保存到实际app.config文件中.我究竟做错了什么?

Mic*_*elS 5

最后发现更改正在.vshost.exe.config保存.

正如Oded所说,这是因为代码是在Visual Studio进程主机下运行的.

请注意,一旦停止进程运行,将恢复更改.