views:

188

answers:

1

Hi,

I am trying to modify the userSettings section (Properties.MyApp.Default) in the MyApp.exe.config file during the installatio of my WPF application using an MSI installer.

I basically implemented it like in this excellent article: http://raquila.com/software/configure-app-config-application-settings-during-msi-install/

The difference is that I am not editing the appSettings but the userSettings section.

The problem is that although the code runs fine, the settings are not saved. After the installation the config file contains the old settings I use in my development environment. I also tried to override OnAfterInstall(System.Collections.IDictionary stateSaver) instead of Install(System.Collections.IDictionary stateSaver) but it doesn't make a difference.

Here is the code that should change the config values:

protected override void OnAfterInstall(IDictionary savedState)
{
    base.OnAfterInstall(savedState);

    string targetDirectory = Context.Parameters["targetdir"];
    string tvdbAccountID = Context.Parameters["TVDBACCID"];
    // read other config elements...

    Properties.Settings.Default.Tvdb_AccountIdentifier = tvdbAccountID;
    // set other config elements

    Properties.Settings.Default.Save();
}

Any idea how to persist these changes? I already read about Wix but that seems like an overkill to me.

Thanks in advance!

A: 

User settings are saved in the current user's local folder, usually looks like C:\Users\Username\AppData\Local\Manufacturer\ApplicationName\Application.exe_StrongName\VersionNumber\user.settings Note that location changes with application versions.

UserSettings section of you exe.config contains default values for new users.

Check this question for more information.

Artem K.
When user settings are saved during an MSI install, they are saved to C:\Users\Username\AppData\Local\Microsoft_Corporation\SomeHash\Version(MSI version?)\user.config.
Nick