robertb_NZ
Well-known member
My VB.NET software is delivered through ClickOnce. When users download a new version their settings are lost and they have to reconfigure it, but I want their settings to be retained as far as possible. How do I achieve this?
I thought that I'd fixed this problem. I found this paper
Client Settings FAQ
This said that the answer was to use the Upgrade function. Of course you only want to call this function the first time that the new version is run, so you define a setting "CallUpgrade" and put code like this in your application's startup code: -
I defined a setting CallUpgrade (Type Boolean, Scope User, Value True), and wrote this code at the beginning of Startup_Load. Startup is the start form of my Windows Form application, it's only function is to wrap the real code in a Try/Catch so that I can get diagnostics when there's a problem.
I thought that this had fixed the problem, but a user reports that they still have to reset their configuration to the previous values. All My.Settings values have scope User, none are Application. So what have I got wrong?
I thought that I'd fixed this problem. I found this paper
Client Settings FAQ
This said that the answer was to use the Upgrade function. Of course you only want to call this function the first time that the new version is run, so you define a setting "CallUpgrade" and put code like this in your application's startup code: -
C#:
if (Properties.Settings.Value.CallUpgrade) {
Properties.Settings.Value.Upgrade();
Properties.Settings.Value.CallUpgrade = false;
}
I defined a setting CallUpgrade (Type Boolean, Scope User, Value True), and wrote this code at the beginning of Startup_Load. Startup is the start form of my Windows Form application, it's only function is to wrap the real code in a Try/Catch so that I can get diagnostics when there's a problem.
VB.NET:
Private Sub Startup_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Try
If My.Settings.CallUpgrade Then '15.5:Settings
My.Settings.Upgrade()
My.Settings.CallUpgrade = False
End If
...