Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting app.config variables in updates via Click once deployment

Every time a new update is released for an application with click once, the variables in the app.config file are destroyed

<userSettings>
    <app.My.MySettings>
      <setting name="Email" serializeAs="String">
        <value />
      </setting>
      <setting name="UserName" serializeAs="String">
        <value />
      </setting>
    </app.My.MySettings>
  </userSettings>

How can i prevent that?

Is there any way of feching the variables from the previous application version?

like image 576
OrElse Avatar asked Mar 07 '09 23:03

OrElse


1 Answers

Do you have the "Applications should check for updates" option checked?

Have a look at Exploring Secrets of Persistent Application Settings (the section titled "Maintaining Settings Between Program Versions"):

For any settings from the current version that match settings in the prior version, this routine will import them into the current version's user.config file:

At the entry point to your program, place the following code.

if (Properties.Settings.Default.UpgradeSettings) 
{
   Properties.Settings.Default.Upgrade();
   Properties.Settings.Default.UpgradeSettings = false;
}

Note that UpgradeSettings is a boolean user setting (not application) that you need to add yourself, and you want the default value to be True.

like image 63
Mitch Wheat Avatar answered Sep 20 '22 16:09

Mitch Wheat