26

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 in the AppData folder for a specific version. Essentially, every release of my application starts from scratch as far as user settings go.

While this is a mild annoyance in development, it raises the question as I approach deployment/release - if I use the app.config to store my user settings, will the user's personalized settings be hosed every time they install a patch that changes the version number of my app? If so, is there an easy way to "upgrade" the settings from the previous release? I know that using HKCU in the registry is another option, but I like the ease of the My.Settings namespace, and I'd like to stay with app.config.

Another SO question asks something similar, though the answer doesn't seem that clear. Will setting my MSI so it asks the user to upgrade be enough to preserve these user-level settings?

4

3 に答える 3

41

ApplicationSettingsBase.Upgrade()を見ましたか? 次の呼び出しを使用して、以前のバージョンから設定をアップグレードできます。

My.Settings.Upgrade()
于 2009-07-30T08:11:28.577 に答える
7

理由はわかりませんが、アップグレード コマンドも以前のバージョンの取得も機能しないようです。私は何が間違っているのでしょうか?更新コマンドなどを呼び出す必要がありますか。フォームの読み込み時にこれを行っていますが、アプリケーション イベントである必要がありますか?

アップデート

理由がわかりました。4 桁のメジャー バージョン番号を使用すると機能しないようです。メジャー バージョン番号として 2012 年を使用していました。私はそれを 12 に変更しました。ミレニアム準拠ではありませんが、魅力的に機能します。それでも、それについて心配し始めるまでに88年かかりました!

于 2012-10-17T09:41:30.603 に答える
1

ClickOnceの展開を検討しましたか?次に、このトピックについて詳しく説明します。IMO、ClickOnceは、開発者とユーザーの両方にとってはるかに簡単です。

于 2009-07-29T06:56:43.553 に答える