question

DinhTon-3484 avatar image
0 Votes"
DinhTon-3484 asked DanielZhang-MSFT commented

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

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.

dotnet-csharpvs-generalwindows-forms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

karenpayneoregon avatar image
1 Vote"
karenpayneoregon answered DanielZhang-MSFT commented

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.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi karenpayneoregon,

Thank you for a very detailed answer. As of now, I'm just trying to stay with ClickOnce as much as I can. If I cannot solve the problem then I'll consider Microsoft Installer project.

I still don't know why my ClickOnce installation folder path is much different from others. Usually, it's

AppName_xxxxxHASHxCODExxxxxxxx\1.0.0.1

and the HASH part stays consistent between versions.

Mine just doesn't have the release number at all and each time I put out a new release, the HASH changes. Did I do anything wrong in the settings?

0 Votes 0 ·

Hi @DinhTon-3484,
Each ClickOnce application is installed in per-user, per-application cache folder. You can find the folder like:
C:\Users\username\AppData\Local\Apps\2.0
More detail please refer to this document.
And the hash code will vary depending on the assembly when it is built.
There are more discussion in this thread.
Best Regards,
Daniel Zhang


1 Vote 1 ·

Hi DanielZhang,

Thanks for the links. There must be something wrong with my projectsettings that prevents the user settings from being copied over to new releases.

If anyone has an idea, please let me know. Thanks.

0 Votes 0 ·
Show more comments