UserSettings lost when application moved - strongname

时间:2018-09-19 08:28:32

标签: c# wpf settings

In my company users are opening applications from a network drive. To update (override) these applications every user has to close the app.

To avoid that I created a app that finds the newest version by foldername. For example:

Folder: 1.0
Folder: 1.0.1
Folder: 1.0.2
Folder: 1.2
Folder: 2.0

AppLauncher.exe

If I click AppLauncher.exe the app in the folder 2.0 launches. The problem is that the UserSettings are always lost on a new version because the application is on another filepath (versionfolder).

In this thread the solution mentioned was to strong-name the application. I can't to that because signing my app means that I have to sign all the other assemblies to. Thats not doable in my case.

Is there any other solution?

1 个答案:

答案 0 :(得分:-1)

看看ApplicationSettingsBase.Upgrade

此方法将先前版本设置与当前设置(在内存中)合并。您可能要保存结果设置。

我的program.cs中有以下代码:

private static void Main(string[] args) {
        Properties.Settings.Default.Upgrade();
        Properties.Settings.Default.UpgradeRequired = false;
        Properties.Settings.Default.Save();
        //Other stuff
}