Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConfigurationManager doesn't save settings to exe.config

(My question is similar to this one, but the code is slightly different, and the solution doesn't work for me)

I'm trying to save settings changes to the 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")

Nothing is saved neither to the exe.config file in bin folder, and not to the actual app.config file. What am I doing wrong?

like image 214
MichaelS Avatar asked Jan 26 '26 07:01

MichaelS


1 Answers

Finally ended finding the changes are being saved under .vshost.exe.config.

As Oded mentioned,that is because the code is being run under the Visual Studio process host.

Note that the changes are being reverted once you stop the process run.

like image 148
MichaelS Avatar answered Jan 27 '26 22:01

MichaelS