Search code examples
c#visual-studio-2010settingsclickoncepublish

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


Solution

  • If you have user-level settings, ClickOnce should copy them forward to the next version's cache when the user gets an update. There are a couple of cases where it doesn't copy the files forward, such as when you change the certificate.

    Application-level settings are not retained and carried forward to the next version.

    I don't recommend using this mechanism and relying on it. You might want to check out [We rolled our own configuration manager, and store the data as XML and store it. This way, you control what happens to the data.

    The only drawback is that when the user uninstalls the app, it leaves this data behind. On the other hand, when the user uninstalls the app, it leaves his data behind, so if he is uninstalling it because he's having a problem, or he clears his ClickOnce cache because he has his problem, then when he installs a new version, his data is still there.