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

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

(我的问题类似于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 文件。我做错了什么?

最佳答案

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

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

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

关于.net - ConfigurationManager 不会将设置保存到 exe.config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8519082/

相关文章:

.net - ASP.NET MVC3 谷歌分析集成

c# - 进程 WaitForExit 不等待

c# - C#/.NET 中的二次规划

vb.net - 什么是手抄本?我可以在 vb.net 中使用它吗?为什么我问过的人都没有听说过它?

c# - 我可以用 LINQ 做到这一点吗?

javascript - 检查用户计算机上是否安装了 .net 4 客户端配置文件

.net - 如何将尾部斜杠附加到页面路由?

c# - 对象关系映射

vb.net - Systems.timer.timer不需要的多线程

vb.net - 可以使用 VB.net 发送普通的 UDP 数据包 - 但是如何发送 WOL 数据包?