0

im using .Net Core 3.1 and WPF for my project and today i was playing a little bit with the settings.All worked fine. I can save values and i can access this values after restart.

After that im increased my assembly value from 1.0.0.0 to 1.0.0.1 and the settings are gone... I searched many hours to fix this issue but i did not found any solution.

Keep user's settings after altering assembly/file version

This was a pretty nice solution but this is not working for me. WHY?

Easy to say after every single file build and access to any Setting.Default values my appilcation generates a new setting folder with an new hash.

So i have multiple folders with each one user.config. Without the single file build it works fine. The new assembly version gets generated in the latest folder and i can update ist like the solution above.

enter image description here

Currently i need so setup my app again on eveery new assembly version :/ Someone had the same issue and can help me? Why is my application creating multiple settings folder for each assemblyversion?

  1. .Net Core 3.1
  2. Visual Studio 2022 (17.2.2)

enter image description here

Kevin V
  • 129
  • 2
  • 9

1 Answers1

-1

You can use the Upgrade method for migrating settings from previous versions.

https://learn.microsoft.com/en-us/dotnet/api/system.configuration.applicationsettingsbase.upgrade?redirectedfrom=MSDN&view=dotnet-plat-ext-6.0#System_Configuration_ApplicationSettingsBase_Upgrade

It notifies all of the corresponding settings providers of the existence of the upgraded application through a call to their IApplicationSettingsProvider.Upgrade method.

You can override the default behavior of Upgrade to implement custom upgrading or merging behavior. Use the GetPreviousVersion method to retrieve individual values for a setting for the previous version of the application.

Lei Zhang-MSFT
  • 280
  • 1
  • 5
  • No i tried this but the upgrade methode only works if the different assembly versions in the same folder. But the single file publishing creates multiple folders with each on assembly. – Kevin V Nov 08 '22 at 19:50
  • I am using Visual studio 2022 (17.3.2) and .NetCore 3.1 for single file replication, but I am not having your problem. You can take a look at this lin'k https://www.codeproject.com/Tips/634188/Upgrading-Settings-files-when-changing-application, I hope it can help you. – Lei Zhang-MSFT Nov 29 '22 at 09:09