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

%3CLINGO-SUB%20id%3D%22lingo-sub-2077279%22%20slang%3D%22en-US%22%3EWPF%2FMSIX%20application%20settings%20not%20getting%20updated%20when%20new%20version%20of%20the%20app%20is%20installed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2077279%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI%20have%20a%20WPF%20app%20that%20I'm%20packaging%20and%20publishing%20(side-loading)%20with%20MSIX.%20Application%20settings%20are%20saved%20in%20a%20class%20that's%20derived%20from%20ApplicationSettingsBase.%20When%20the%20app%20is%20installed%20and%20runs%2C%20those%20settings%20are%20saved%20to%20disk%20in%20user.config%20in%20a%20directory%20something%20like%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EC%3A%5CUsers%5C...%5CAppData%5CLocal%5CPackages%5Ceb585c83...%5CLocalCache%5CLocal%5CWpfApp1%5CWpfApp1_Url_0h0wlkyvmedald25z34yc2xsbwcm4nil%5C2.0.0.0%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E2.0.0.0%20is%20the%20app's%20version%20number.%20If%20I%20create%20a%20new%20version%20of%20the%20app%2C%202.0.1.0%20for%20example%2C%20a%20new%20user.config%20is%20created%20but%20the%20settings%20from%20version%202.0.0.0%20are%20not%20copied%20to%20the%20new%20user.config.%20The%20new%20user.config%20is%20in%20a%20new%20directory%20like%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E...%5CLocalCache%5CLocal%5CWpfApp1%5CWpfApp1_Url_a3i1rd2xrwh3qbg3x15jaaizhfueup20%5C2.0.1.0%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20sounds%20like%20ApplicationSettingsBase.Upgrade%20is%20supposed%20to%20update%20the%20new%20config%20with%20settings%20from%20the%20old%20version%20but%20it's%20not%20working.%26nbsp%3BIf%20I%20put%20the%202.0.0.0%20directory%20in%20the%20same%20directory%20as%202.0.1.0%2C%20then%20the%20upgrade%20works.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20use%20Visual%20Studio's%20%22Deploy%22%20feature%2C%20the%20version%20directories%20are%20in%20the%20same%20parent.%20I.e.%20it%20works.%20It's%20publishing%2Fside-loading%20that%20has%20a%20problem.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20idea%20what%20could%20be%20wrong%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2122468%22%20slang%3D%22en-US%22%3ERe%3A%20WPF%2FMSIX%20application%20settings%20not%20getting%20updated%20when%20new%20version%20of%20the%20app%20is%20installed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2122468%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F935487%22%20target%3D%22_blank%22%3E%40ChuckBohling%3C%2FA%3E%2C%20what%20version%20of%20Windows%20are%20you%20testing%20on%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2122770%22%20slang%3D%22en-US%22%3ERe%3A%20WPF%2FMSIX%20application%20settings%20not%20getting%20updated%20when%20new%20version%20of%20the%20app%20is%20installed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2122770%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F935487%22%20target%3D%22_blank%22%3E%40ChuckBohling%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20was%20looking%20up%20what%20might%20be%20happening%2C%20and%20found%20this%20post.%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsocial.msdn.microsoft.com%2FForums%2Fvstudio%2Fen-US%2Fc05e66d0-06fc-4e57-9522-5db313b48f13%2Fsaving-user-settings-on-version-update%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESaving%20User%20Settings%20on%20Version%20Update%20(microsoft.com)%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20comment%20towards%20the%20end%20suggests%20that%20if%20you%20are%20switching%20between%20debug%20and%20retail%20the%20paths%20may%20not%20be%20the%20same.%26nbsp%3B%20%26nbsp%3BCan%20you%20verify%20that%20both%20apps%20are%20built%20retail%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%3C%2FP%3E%0A%3CP%3EKevin%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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.