User.Settings 文件在 ClickOnce 更新时恢复值
我已经阅读了这里的许多问题,甚至还发布了我自己的一个问题,试图深入了解这一点(我之前的问题)。不幸的是,他们都没有回答我的问题。每当我通过 ClickOnce 部署更新时,我的 .Settings
文件就会重置。我认为 ClickOnce 应该为我处理这类事情,但由于似乎没有,我使用设置标志实现了 .Upgrade()
,如下所示:
if (Settings.Default.MustUpgradeSettings)
{
Settings.Default.Upgrade();
Settings.Default.MustUpgradeSettings = false;
Settings.Default.Save();
}
我检查 OnLoad()< /代码>。我错过了什么吗?这真的让我发疯了!
我还在 MSDN 上发布了此内容
I have read the numerous questions here on this and even posted one of my own trying to get to the bottom of this(My Previous Question). Unfortunately, none of them answer my question. My .Settings
file get's reset whenever I deploy an update through ClickOnce. I thought ClickOnce was supposed to handle this sort of thing for me but since it seems no, I implemented the .Upgrade()
with a Settings Flag like so:
if (Settings.Default.MustUpgradeSettings)
{
Settings.Default.Upgrade();
Settings.Default.MustUpgradeSettings = false;
Settings.Default.Save();
}
Which I check OnLoad()
. Am I missing something? This is seriously driving me nuts!
I have also posted this at MSDN, HERE, and they are even less help then SO so far. I just know that I will end up with "egg and my face in alignment" when this is all over I just wish someone could point that out for me...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信它应该做到这一点,至少从我在这里读到的内容来看是这样。
http://msdn.microsoft.com/en-us/library/ms228995.aspx
正如 ClickOnce 应用程序的每个版本都与所有其他版本隔离一样,ClickOnce 应用程序的应用程序设置也与其他版本的设置隔离。当您的用户升级到应用程序的更高版本时,应用程序设置会将最新(编号最高)版本的设置与更新版本提供的设置进行比较,并将这些设置合并到一组新的设置文件中。
I believe it's supposed to do that, at least from what I'm reading here.
http://msdn.microsoft.com/en-us/library/ms228995.aspx
Just as each version of a ClickOnce application is isolated from all other versions, the application settings for a ClickOnce application are isolated from the settings for other versions as well. When your user upgrades to a later version of your application, application settings compares most recent (highest-numbered) version's settings against the settings supplied with the updated version and merges the settings into a new set of settings files.
仅供参考:对我来说也不起作用。
它应该做的一切,它都没有(MustUpgradeSettings 未被检测为 true,但无论如何升级功能都不起作用。GetPreviousSettings 函数也返回默认值。
不明白为什么没有其他投诉对此
可能的解决方案是 DIY
FYI: Does not work for me either.
Everything it should do, it does not (MustUpgradeSettings isn't detected as true, but regardless of that the Upgrade function does not work. GetPreviousSettings function returns defaults too.
Don't understand why there are no other complaints about this
Possible solution is DIY