Automatically “upgrade” user settings from previous version of app.config file?

后端 未结 3 540
故里飘歌
故里飘歌 2020-12-08 10:29

Every time I compile my app and the version number changes (I have an auto-incrementing build number), I lose the user-configured app.config settings, since they\'re stored

相关标签:
3条回答
  • 2020-12-08 10:49

    Have you looked at ApplicationSettingsBase.Upgrade()? It allows the settings to be upgraded from a previous version using the following call:

    My.Settings.Upgrade()
    
    0 讨论(0)
  • 2020-12-08 11:05

    Not sure why but neither the upgrade command or the get previous version seems to work for me. What could I be doing wrong? Do I need to call a refresh command or something. I am doing this on form load, should it be an application event?

    UPDATE

    Found out why, it seems it does not work when you use a 4 digit major version number. I was using the year 2012 as the major version number. I have changed that to 12 and it works like a charm, though is no not millenium compliant. Still I got 88 years before I need to start worrying about that!

    0 讨论(0)
  • 2020-12-08 11:05

    Have you considered ClickOnce deployment? This topic is then covered in depth. IMO, ClickOnce is much easier both for the developer and the user.

    0 讨论(0)
提交回复
热议问题