【问题标题】:How can I get for reading and writing Properties.Settings.Default.UpgradeRequired property?如何获得读写 Properties.Settings.Default.UpgradeRequired 属性?
【发布时间】:2017-01-20 07:45:40
【问题描述】:

在我的 WPF MVVM 应用程序中,我需要检查我的应用程序是否在安装后首先运行。我查看了 SO 中的一些示例,其中一个示例 - how to check whether my c# window app is running first time after installation 我发现以下代码,作者建议使用 UpgradeRequired:

// this must happen as soon as your program starts, before
// you do anything else with the settings
if (Properties.Settings.Default.UpgradeRequired)
{
    // upgrade FIRST, before doing anything else with the settings
    Properties.Settings.Default.Upgrade();
    Properties.Settings.Default.UpgradeRequired = false;
    Properties.Settings.Default.Save();
}

我在这里引用他的话:“我还建议在默认情况下为 true 的设置中添加一个“UpgradeRequired”布尔值......”但是当我尝试在我的 App.xaml.cs 文件中添加相同的代码时OnStartUp 事件处理程序然后发生以下错误:“设置不包含 UpgradeRequired 的定义”并且 UpgradeRequired 带有红色波浪线下划线。我以前没有遇到过 Properties.Settings 。所以我想知道:我应该将哪个程序集引用添加到我的应用程序中?我必须做什么才能访问 Properties.Settings.Default.UpgradeRequired?我们将不胜感激。

【问题讨论】:

    标签: c# wpf application-settings


    【解决方案1】:

    这不是在任何程序集中,它是您的自定义设置。这里都解释了https://msdn.microsoft.com/en-us/library/a65txexh(v=vs.140).aspx

    【讨论】:

    • 谢谢你,MotKohn。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-08
    • 1970-01-01
    • 2011-06-23
    • 1970-01-01
    • 2022-10-13
    • 2022-01-21
    相关资源
    最近更新 更多