Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Published a ClickOnce application and it keeps resetting its settings

I have deployed this application using Visual Studio 2010's Publish feature; it needs to save a few user settings (such as database connection information) and there is this particular computer that somehow keeps resetting the application's settings. The part that puzzles me the most is that I have not been able to figure out under what circumstances or the reason why this happens. I know the settings are getting set properly because the application has worked just fine on 6 or 7 other computers.

What could be erasing the application's settings? Alternatively, what would you suggest I use to store those settings? An encrypted file?

EDIT: I am using the default application settings. They are defined in the app.config file. They can be accessed using Properties.Settings.Default.propertyName

like image 247
Ozzyberto Avatar asked Aug 21 '12 16:08

Ozzyberto


People also ask

How do I turn off ClickOnce security settings?

To disable ClickOnce security settings With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Security tab. Clear the Enable ClickOnce Security Settings check box.

Where are ClickOnce settings stored?

config file is stored in the user's Documents and Settings folder. In a ClickOnce application, <app>.exe. config lives in the application directory inside of the ClickOnce application cache, and user. config lives in the ClickOnce data directory for that application.

How do I publish my ClickOnce website?

To specify a custom Web page for a ClickOnce applicationSelect the Publish pane. Click the Options button to open the Publish Options dialog box. Click Deployment. In the Publish Options dialog box, make sure that the Open deployment web page after publish check box is selected (it should be selected by default).


1 Answers

For anyone who runs into this problem: Check if you have an unconditional

Properties.Settings.Default.Upgrade();

in your code. In a ClickOnce installation with multiple versions, this statement copies the user settings from a previous version and overwrites any settings that were saved in the last session. The correct pattern is:

if (Properties.Settings.Default.UpgradeRequired)
{
    Properties.Settings.Default.Upgrade();
    Properties.Settings.Default.UpgradeRequired = false;
    Properties.Settings.Default.Save();
}

where UpgradeRequired is a setting that defaults to true.

like image 134
jerha202 Avatar answered Sep 22 '22 12:09

jerha202