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

我们两清 提交于 2019-12-22 04:17:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3498561/net-applicationsettingsbase-should-i-call-upgrade-every-time-i-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!