Keith

Keith

  • NA
  • 6
  • 0

Maintaining custom config sections accross application updates

Sep 3 2010 6:31 AM
I have a Visual C# 2008 Express project which I deploy via ftp to a website using ClickOnce deployments.

My application has a custom configuration section in app.config as shown below:

<configSections>
    <section name="WatchConfiguration" type="WindowsFormsApplication1.WatchConfiguration, ShareDetective" />
  </configSections>

<WatchConfiguration>
    <Watches />
  </WatchConfiguration>

I'm loading and referencing the section like this:

ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = sConfigFilename;
this.oApplicationConfiguration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
this.oWatchConfig = (WatchConfiguration)this.oApplicationConfiguration.GetSection("WatchConfiguration");

I have the config bound to various fields on a config form. Which all works fine.

I save the config like this:

 this.oConfigApplicationConfiguration.Save();

This all works fine and persists the config accross application sessions.

However, the configuration is lost on each publish of a new version of the application using ClickOnce deployments.

I've google and read numerous articles on persisting settings accross updates and all seem to reference "settings" which isn't really what I'm using. Maybe I should be.

Any help would be greatly appreciated!!

Answers (2)