Why are persisted user settings not loaded? Why are persisted user settings not loaded? windows windows

Why are persisted user settings not loaded?


If you are recompiling the application between runs, note that it will consider that a new version of the app and will not automatically load per-user settings. You need to call Settings.Default.Upgrade in this situation.

One way to do this only when needed is to add a NeedsUpgrade setting (value True) to the application's default per-user settings. On app startup, check if NeedsUpgrade is true. If so, call Upgrade, set NeedsUpgrade to False, and save the settings. The next time the app version changes, NeedsUpgrade will reset to True and you'll auto-call Upgrade to bring in any existing user settings again.

Make sure you're setting NeedsUpgrade after calling Upgrade, or it will get wiped out when the settings are upgraded.

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


This sounds like you're debugging the application from Visual Studio when every time you start a new session you start with the default data.

If you're seeing this with an installed release, then I would guess you're not actually using the string values when you think you are.