Link to home
Start Free TrialLog in
Avatar of dominicwong
dominicwong

asked on

Trouble with persisting user settings when install new version

Hi experts
I have some trouble in restoring persisted user config settings when installing a new version of my C# .NET application.

I have the following lines right at the beginning of my main program:
       // if(Properties.Settings.Default.UpgradeSettings). Temporary took out for testing
       {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeSettings = false;
                Properties.Settings.Default.Save();
        }

Open in new window


The old settings was kept in the file "user.config" at the location:
C:\Users\dwong\AppData\Local\Company\MyTool.exe_Url_bp2u4og4vwazxwbxllvfhrz3ph3omcfd\1.1.0.4

After installing the new version, I could see a new "user.config" at a new location:
C:\Users\dwong\AppData\Local\Company\MyTool.exe_Url_pjgudcgzuigkvokmjnwldqaecw2hgaz5\1.1.0.5

But the code above didn't copy the old user settings, could someone point to me where I might have done wrong.

FYI, I am using C#, .NET 3.5, Installer.

Thanks in advance.
SOLUTION
Avatar of Vikram Singh Saini
Vikram Singh Saini
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dominicwong
dominicwong

ASKER

Thanks Vikram Singh Saini.
I'd taken a look at the link and the approach is similar to what I did.

I'd created an empty project, and retested my original approach. The issue seems to be related to the different directory path that was created in the 'AppData\Local' directory by my original program:
C:\Users\dwong\AppData\Local\Company\MyTool.exe_Url_bp2u4og4vwazxwbxllvfhrz3ph3omcfd\1.1.0.4
C:\Users\dwong\AppData\Local\Company\MyTool.exe_Url_pjgudcgzuigkvokmjnwldqaecw2hgaz5\1.1.0.5


My new empty test project put all the new versions under the same directory as:
C:\Users\dwong\AppData\Local\WfApplication1\WfApplication1._Url_tsje4qn52nzeqpaxfmlrpijgg1rryu4g\1.0.0.0
C:\Users\dwong\AppData\Local\WfApplication1\WfApplication1._Url_tsje4qn52nzeqpaxfmlrpijgg1rryu4g\1.0.0.1
C:\Users\dwong\AppData\Local\WfApplication1\WfApplication1._Url_tsje4qn52nzeqpaxfmlrpijgg1rryu4g\1.0.0.2
C:\Users\dwong\AppData\Local\WfApplication1\WfApplication1._Url_tsje4qn52nzeqpaxfmlrpijgg1rryu4g\1.0.0.3


The question is what triggers my original program to create a different path everytime? Any idea?

Thanks in advanec
Mind if you can share your test project for testing purpose.

Just want to give it try to experience same weird issue.
Thanks Vikram Singh Saini.

The test project actually works fine. It generated the same hash for every new version, and put the 'user.config' for any subsequent newer versions under the same directory.
   C:\Users\{User}\AppData\Local\{CompanyName}\{ExecutableName}_Url_hash\1.0.0.x

The weird issue is, therefore, not with the test project but rather with my original project which generated a different hash every time.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Vikram Singh Saini for your offer to help.