Proper way to upgrade WPF program settings on program update (Desktop Bridge/Project Centennial)

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:56:18

问题


When it was a clickonce program it worked, but then I made an appxpackage and exported it as a centennial app for windows store and the upgrade does not work any more.

Right now I have in App.xaml.cs

protected override void OnStartup(StartupEventArgs e) {
   if (myprog.Properties.Settings.Default.UpgradeRequired)
   {    
      myprog.Properties.Settings.Default.Upgrade();
      myprog.Properties.Settings.Default.UpgradeRequired = false;
      myprog.Properties.Settings.Default.Save();
   }

With UpgradeRequired as a bool in user settings. Is that the right place?

I am getting settings reset on each version update. Now I have several of these directories

C:\Users\me\AppData\Local\progname\prog.exe_Url_randomChars

each with several different version of program settings. So after the upgrade another one of those is created, instead a subfolder with x.x.x.x of the current version.

As before, on each version release I increase version in Assembly Information the Assembly Version, File Version, and now I have the same numbers in AppxManifest.xml. I keep the last number group of the version to 0 as advised, and just increase the 3rd number group.

Is there something I am missing?


回答1:


UWP and Desktop Bridge apps need to store their settings in ApplicationData.LocalSettings:

https://docs.microsoft.com/en-us/windows/uwp/design/app-settings/store-and-retrieve-app-data#local-app-data



来源:https://stackoverflow.com/questions/41391182/proper-way-to-upgrade-wpf-program-settings-on-program-update-desktop-bridge-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!