Solved

Trouble with persisting user settings when install new version

Posted on 2014-11-20
6
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 200 total points
ID: 40457207
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
ID: 40461101
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
ID: 40461349
Mind if you can share your test project for testing purpose.

Just want to give it try to experience same weird issue.
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 

Author Comment

by:dominicwong
ID: 40461391
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
ID: 40469833
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
ID: 40475518
Thanks Vikram Singh Saini for your offer to help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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