Solved

Trouble with persisting user settings when install new version

Posted on 2014-11-20
6
148 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

26 Experts available now in Live!

Get 1:1 Help Now