2011-12-15 26 views
3

(我的問題是類似this one,但代碼略有不同,該解決方案不爲我工作)ConfigurationManager中不保存設置exe.config

我想保存設置的更改到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") 

沒有被保存既不到exe.config文件中的bin文件夾,而不是實際的app.config文件。我究竟做錯了什麼?

+0

您是否收到任何錯誤?例外?你看過`Debug`和`Release`文件夾嗎? – Oded 2011-12-15 11:13:16

回答

5

終於結束了尋找更改保存下.vshost.exe.config

如前所述Oded,這是因爲代碼被Visual Studio的過程中主機下運行。

注意,一旦你停止運行過程的變化正在恢復。