简体   繁体   English

.NET ApplicationSettingsBase我每次加载时都应该调用Upgrade()吗?

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

We have application settings derived from ApplicationSettingsBase . 我们有从ApplicationSettingsBase派生的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? 我的问题是为什么不在每次实例化设置时调用Upgrade() That way i know I will never be out of date. 这样我知道我永远不会过时。

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 . 当您的应用程序版本更改时,设置将重置为其默认值, UpdateRequired属性将为true

So no, you don't have to call Upgrade every time your app starts. 所以不,每次你的应用程序启动时你都不必调用Upgrade

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ApplicationSettingsBase.Upgrade() 使用 .NET 4.0 重新编译后不升级用户设置 - ApplicationSettingsBase.Upgrade() Not Upgrading User Settings after Recompiling with .NET 4.0 每次我在 ASP.NET MVC 中调用操作时都会创建数据库上下文 - DB Context is created every time I call an Action in ASP.NET MVC 如何使用ApplicationSettingsBase将自定义类保存到用户设置? - How do I save a custom class to user settings using ApplicationSettingsBase? 我应该在每个等待的操作上调用ConfigureAwait(false) - Should I call ConfigureAwait(false) on every awaited operation 每次升级我的dotNet应用程序使用的COM库时,是否需要重建和重新部署? - Do I need to rebuild and redeploy every time I upgrade a COM library used from my dotNet app? 每次刷新页面时如何加载用户? - How can I load user every time the page is refreshed? 每次调用方法时,List都会被初始化 - List is getting initialized every time I call method 我应该在什么时间和上下文中调用ThreadPool.SetMinThreads - At which time and in which context should I call ThreadPool.SetMinThreads 为什么要升级到C#4.0? - Why should I upgrade to c# 4.0? 如果我每次创建它时都被迫重新启动每个粒子,我是否应该使用Pools作为粒子 - Should I use Pools for particles if i forced to re-init every particle every time i create them
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM