views:

215

answers:

1

I have a WinForms app that uses the Settings feature of .NET 2, but the User scope settings values saved in the application often get replaced by the default values stored in the Settings class. Long ago I found guidance somewhere that attributed this to an auto-incrementing build number, and I suspect this is true. However, said guidance suggested the following code, but somehow my settings still keep getting reset.

I'm solving too many other issues at the moment to go into this any deeper than this, bu tI thought I'd through the question out and see if someone can help me, and everyone else with this problem.

    private void Form1_Load(object sender, EventArgs e)
    {
        UpgradeSettings();
        GetSettings();
    }

    private void UpgradeSettings()
    {
        if (Properties.Settings.Default.CallUpgrade)
        {
            Properties.Settings.Default.Upgrade();
            Properties.Settings.Default.CallUpgrade = false;
        }
    }
A: 

Does CallUpgrade default to true? The call to Upgrade() should migrate settings across build numbers.

Another approach is to use fixed build numbers. You can manually modify your AssemblyInfo.cs as needed.

Arnshea