Settings.settings文件状态越来越重设 [英] Settings.settings File Keeps Getting Reset

查看:145
本文介绍了Settings.settings文件状态越来越重设的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试我的项目在Visual Studio 2008中,我Settings.settings文件弟妹复位之间架起。有没有办法来防止这种情况的发生?

When debugging my project in Visual Studio 2008, my Settings.settings file keeps getting reset between builds. Is there a way to prevent this from happening?

感谢。

推荐答案

好吧,我找到了答案,我真的很期待的。基本上,你需要调用LocalFileSettingsProvider.Upgrade。但是,由于我将使用ClickOnce部署,它会自动为你做它。

Okay, I found out the answer I was really looking for. Basically, you need to call LocalFileSettingsProvider.Upgrade. However, since I will be deploying using ClickOnce, it will do it for you automatically.


问:好吧,但我怎么知道何时调用升级

Q: Okay, but how do I know when to call Upgrade?

?答:好问题。在ClickOnce的,当你安装你的应用程序的新版本,ApplicationSettingsBase会检测到它,并自动以设定加载点升级你的设置。在非的ClickOnce情况下,没有自动升级 - 您必须调用升级自己。下面是用于确定何时调用升级一个想法:

A: Good question. In Clickonce, when you install a new version of your application, ApplicationSettingsBase will detect it and automatically upgrade settings for you at the point settings are loaded. In non-Clickonce cases, there is no automatic upgrade - you have to call Upgrade yourself. Here is one idea for determining when to call Upgrade:

有一个名为CallUpgrade一个布尔值设置,并给它真正的默认值。当你的应用程序启动时,你可以这样做:

Have a boolean setting called CallUpgrade and give it a default value of true. When your app starts up, you can do something like:

if (Properties.Settings.Value.CallUpgrade)
{
    Properties.Settings.Value.Upgrade();
    Properties.Settings.Value.CallUpgrade = false;
}

这将确保升级()被调用仅在第一次运行该应用程序。后一个新版本部署

This will ensure that Upgrade() is called only the first time the application runs after a new version is deployed.

REF: HTTP: //blogs.msdn.com/rprabhu/articles/433979.aspx

这篇关于Settings.settings文件状态越来越重设的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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