WPF/MSIX application settings not getting updated when new version of the app is installed

Copper Contributor

I have a WPF app that I'm packaging and publishing (side-loading) with MSIX. Application settings are saved in a class that's derived from ApplicationSettingsBase. When the app is installed and runs, those settings are saved to disk in user.config in a directory something like:

 

C:\Users\...\AppData\Local\Packages\eb585c83...\LocalCache\Local\WpfApp1\WpfApp1_Url_0h0wlkyvmedald25z34yc2xsbwcm4nil\2.0.0.0

 

2.0.0.0 is the app's version number. If I create a new version of the app, 2.0.1.0 for example, a new user.config is created but the settings from version 2.0.0.0 are not copied to the new user.config. The new user.config is in a new directory like:

 

...\LocalCache\Local\WpfApp1\WpfApp1_Url_a3i1rd2xrwh3qbg3x15jaaizhfueup20\2.0.1.0

 

It sounds like ApplicationSettingsBase.Upgrade is supposed to update the new config with settings from the old version but it's not working. If I put the 2.0.0.0 directory in the same directory as 2.0.1.0, then the upgrade works. 

 

If I use Visual Studio's "Deploy" feature, the version directories are in the same parent. I.e. it works. It's publishing/side-loading that has a problem.

 

Any idea what could be wrong?

4 Replies

Hi @ChuckBohling, what version of Windows are you testing on?  

Hey @ChuckBohling 

I was looking up what might be happening, and found this post.  Saving User Settings on Version Update (microsoft.com)

 

The comment towards the end suggests that if you are switching between debug and retail the paths may not be the same.   Can you verify that both apps are built retail?

 

Thanks

Kevin

 

@KevinLa_ms Thanks for the finding that post. Unfortunately, it didn't help.

 

For my tests, I used Visual Studio 2019 and published (side-loaded) my app as MSIX. The app was built in release (retail?) mode. I first built, published and installed version 1.0.0.0 then built, published and updated version 1.0.1.0. After the update, my LocalCache has two user.config files (1.0.0.0 and 1.0.1.0) but in different directories.