Solved

Trouble with persisting user settings when install new version

Posted on 2014-11-20
6
145 Views
Last Modified: 2014-12-02
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.
0
Comment
Question by:dominicwong
  • 4
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 200 total points
Comment Utility
But the code above didn't copy the old user settings, could someone point to me where I might have done wrong.

Well! I don't think you are doing wrong at any point.

However can you delete the respective Company folder in Local folder in AppData? And then test same again.

I would suggest link at Automatically upgrading user settings after an application version change
0
 

Author Comment

by:dominicwong
Comment Utility
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
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
Comment Utility
Mind if you can share your test project for testing purpose.

Just want to give it try to experience same weird issue.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:dominicwong
Comment Utility
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.
0
 

Accepted Solution

by:
dominicwong earned 0 total points
Comment Utility
Found the issue was due to appending a version number to the 'ProductName' in the installer setup project. That somehow triggered a new path to be created for the user.config upon every new release.
0
 

Author Closing Comment

by:dominicwong
Comment Utility
Thanks Vikram Singh Saini for your offer to help.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now