I want to save some settings on a config file for future use.
I’m trying to use the regular code that I see on all the tutorials –
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["username"].Value = m_strUserName;
// I also tried -
//config.AppSettings.Settings.Remove("username");
//config.AppSettings.Settings.Add("username", m_strUserName);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
Now – I can see that on runtime – the file “…vshost.exe.config” on “Debug” folder is changes, nut when I close my application – all the changes are deleted.
What can I do?
To test using the normal exe’s config file un-check the box for “Enable the Visual Studio Hosting Process” in the “Debug” tab in the project properties menu. That will make visual studio no-longer use the
vshost.exefile to launch and the correct config file will be used.