Settings.Default.Upgrade does not copy over the user settings to new release

asked 2021-04-12T10:06:38.903+00:00
Dinh Ton 1 Reputation point

Hello,

I'm writing a console app in Winform with Visual Studio 2019. I want the user settings to persist every time I release a new version. I'm using this piece of code to do that.

            if (Properties.Settings.Default.UpgradeRequired)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

However, the settings are reverted back to the default values every time. In addition, I noticed that my app installation folder changes for every release (the HASH part) and the version number is not included. For example, this is what the path looks like.

C:\Users\xxx\AppData\Local\Apps\2.0\M9RKB9NV.1QT\XYMMZD4C.RLW\m7qu..tion_14d5d5ddec12ce36_0001.0000_2b5649f39c6c7441

I did sign the ClickOnce manifests with a Test certificate. I also set the version number to increase automatically every release. (Please ask me if you need more information regarding my project properties).

Please help me with this issue. Thanks in advance.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,314 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,393 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,918 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2021-04-12T10:28:21.573+00:00
    Karen Payne MVP 29,131 Reputation points Microsoft MVP

    Hello,

    If these instructions don't help consider the following but when don't just try this first solution, read through the article.

    Take a look at the following Microsoft Installer project in place of ClickOnce. You set the path e.g. C:\Program Files (x86)\PayneSoftware\SomeApplication.

    There is documentation to read before trying.

    We used this installer with signing and a local SQL-Server database.

    Can't speak about app.config with settings done conventionally, ours are done using appSetting section and after four years never had a need to add or remove settings.

    We use VeriSign for signing.

    So the above is an alternative to ClickOnce.