.NET ApplicationSettingsBase Should I call Upgrade() every time I load?
Asked Answered
B

1

8

We have application settings derived from ApplicationSettingsBase. When we push a new version of our app we need to call:

  //
  // Summary:
  //     Updates application settings to reflect a more recent installation of the
  //     application.
  public virtual void Upgrade();

(from the meta-data)

Now there are some tricky ways to determine if your settings need to be upgraded such as this post which would seem to me to only ever upgrade your settings once. Now I could store the current version of my application in the settings and compare whenever I instantiate the settings, if it is different to the current version then I could upgrade.

My question is why not just call Upgrade() every time I instantiate the settings? That way i know I will never be out of date.

Bello answered 17/8, 2010 at 0:51 Comment(2)
the link no longer worksSermon
I found a cached copy from the web archive, so changed the link to that.Bello
C
6

The method described in the linked post does work. I've used that method myself. When your application version changes the settings will be reset to their defaults and the UpdateRequired property will be true.

So no, you don't have to call Upgrade every time your app starts.

Connoisseur answered 17/8, 2010 at 1:12 Comment(1)
of course! when a new version gets installed a new version of the settings gets created. I was thinking that the old version would get instantiated and then upgraded to the new settings when in fact the new settings will import the old ones.Bello

© 2022 - 2024 — McMap. All rights reserved.