Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
748 views
in Technique[技术] by (71.8m points)

visual studio 2005 - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...