David

David

  • NA
  • 2
  • 0

Ideas to save a CustomConfigurationFile

Jul 24 2008 10:26 AM
Hello, i have a web.application with different customconfiguration files. Thing is i can read them perfectly and can change the value but when i try to save the changes, the format of the file changes and then the application does not recognises the format. To read the file i use the object Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationPath);
This is my web.application
[code]
<configSections>
    <section name="CommonApplicationConfiguration" type="MYProj.Common.Configuration.CommonApplicationConfiguration, MYProj.Common" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" />
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" />
  </configSections>
[/code]

And this is an example of the file content:
[code]<CommonApplicationConfiguration>
  <AppConfiguration>
    <add key="MainWindowState" value="Normal" />
    <add key="HasMainWindowState" value="true" />
    <add key="Width" value="800" />
    <add key="Height" value="600" />
   </AppConfiguration>
</CommonApplicationConfiguration>
[/code]

Basically when i save it the format of the file changes and as it is a requirement that the first tag in the file must be named the same as the section (CommonApplicationConfiguration in this case) the next time the application does not recognise it. Any ideas on how to work around this?