【发布时间】:2011-03-14 19:54:21
【问题描述】:
我正在尝试在 app.config 运行时从它获取更新值。我尝试了几种方法,但它仍然使用旧值。我怎样才能正确刷新它?我试过这些,但没有用:
MessageBox.Show(Properties.Settings.Default.MyValue);
Properties.Settings.Default.Reload();
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.Reset();
ConfigurationManager.RefreshSection("applicationSettings");
ConfigurationManager.RefreshSection("/applicationSettings/");
ConfigurationManager.RefreshSection("/configuration/applicationSettings");
MessageBox.Show(Properties.Settings.Default.MyValue);
MyValue 的值是“第一个值”。
这首先显示“第一个值”。虽然消息框仍处于打开状态,但我手动将其从 my.exe.config 更改为“第二个值”,第二个消息框仍显示“第一个值”。我没有运行解决方案,我是直接运行 bin 文件夹中的 exe,所以不是 vshost 问题。
我该怎么办?
【问题讨论】:
标签: .net configuration configuration-files app-config