The configuration file has been changed by another program.

Topics: Enterprise Library Core, General discussion
Apr 26, 2010 at 6:57 PM
Edited Apr 26, 2010 at 6:59 PM

Hi all,

Declaring section include

    <section name="CustomSettings"  type="TestApp.CustomSettings.CustomSettingsSection,TestApp" allowLocation="true" allowDefinition="Everywhere" />
  <CustomSettings configSource=".\CustomSettings.xml" />

making changes to any values within that section and trying to save twice

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

CustomSettingsSection section = (CustomSettingsSection)config.Sections["CustomSettings"];

section.Settings["SomeSetting"].Value = "Value" ;


 section.Settings["SomeSetting"].Value = "NewValue";


 will result in an exception

 System.Configuration.ConfigurationErrorsException occurred
  Message="The configuration file has been changed by another program. (D:\\projects\\samples\\06 - Config\\bin\\Debug\\CustomSettings.xml)"
  BareMessage="The configuration file has been changed by another program."
  Filename="D:\\projects\\samples\\06 - Config\\bin\\Debug\\CustomSettings.xml"
       at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
       at System.Configuration.Configuration.SaveAsImpl(String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll)
       at System.Configuration.Configuration.Save()
       at ConfigConsoleApplication.Program.Main() in D:\projects\samples\06 - Config\Program.cs:line 165

I test another application, using app.config and extern files config (configsource) and I get the same error.

Any help, please ?? Greetings, Thanks !!!

Apr 27, 2010 at 12:03 AM

Please post this in other forums, like here -


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.