.NET ApplicationSettingsBase我应该叫升级()我每次加载时间? [英] .NET ApplicationSettingsBase Should I call Upgrade() every time I load?

查看:176
本文介绍了.NET ApplicationSettingsBase我应该叫升级()我每次加载时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经从 ApplicationSettingsBase 派生的应用程序设置。当我们把我们的应用程序的新版本中,我们需要调用

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.

推荐答案

在联交所描述的方法确实可行。我用这种方法我自己。当你的应用程序版本更改的设置将被重置为默认值和 UpdateRequired 属性为

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.

这篇关于.NET ApplicationSettingsBase我应该叫升级()我每次加载时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆