I\'m trying to persist user settings to a configuration file using ConfigurationManager.
I want to scope these settings to the user only, because application changes
You need to set the SectionInformation.AllowExeDefinition value for the section:
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
UserSettings settings;
if ((settings = (UserSettings)configuration.Sections[GENERAL_USER_SETTINGS]) == null)
{
settings = new UserSettings();
settings.SectionInformation.AllowExeDefinition =
ConfigurationAllowExeDefinition.MachineToLocalUser;
configuration.Sections.Add(GENERAL_USER_SETTINGS, settings);
configuration.Save();
}
The default value is ConfigurationAllowExeDefinition.MachineToApplication which allows only to place the section on machine.config and app.exe.config.