When I change a configuration property and call the Save () method on the configuration object, and then change the config property and call Save () again, I get an exception because the config has been changed.
Exception text: "The configuration file was changed by another program."
So, if the user changes and saves something at runtime, but changes something, and saving my application will throw an exception. I'm right?
Is it possible to save the configuration several times?
EDIT: Provided sample code.
ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.LocalUserConfigFilename = UserConfig; map.RoamingUserConfigFilename = RoamingConfig; map.ExeConfigFilename = AppConfig; System.Configuration.Configuration combinedConfigFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.PerUserRoamingAndLocal); AddinConfiguration combinedConfig = (AddinConfiguration)combinedConfigFile.GetSection(sectionName); combinedConfig.Config = combinedConfigFile; return combinedConfig;
I have included the Config property in my section to use it to save the configuration as follows.
mySection.Config.Save();
Vajda source share