I have application settings working for my dll however I can't seem to
get the same result with user settings? I assume I need to open 2
configuration managers as shown below. Any idea what I'm missing? If I
try and save the user settings using DllUserConfig.Save() it raises a
general configurationexception.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="UserSettings" type="DllConfig.UserSection,
DllConfig, Culture=neutral, PublicKeyToken=null" />
<section name="MenuSettings" type="DllConfig.ApplicationSection,
DllConfig, Culture=neutral, PublicKeyToken=null" />
</configSections>
<MenuSettings menuName="Test menu name" />
<UserSettings userName="test user name" />
</configuration>
And relevant code:
public Class1()
{
this.GetConfigurationManagers();
_AppSection = _DllConfig.GetSection("MenuSettings") as
ApplicationSection ?? new ApplicationSection();
_UserSection = _DllUserConfig.GetSection("UserSettings")
as UserSection ?? new UserSection();
}
private void GetConfigurationManagers()
{
Assembly asm = Assembly.GetAssembly(this.GetType());
ExeConfigurationFileMap map = new
ExeConfigurationFileMap();
map.ExeConfigFilename = Path.GetFullPath(asm.Location) +
".config";
map.RoamingUserConfigFilename =
Path.GetFullPath(asm.Location) + ".User" + ".config";
_DllConfig =
ConfigurationManager.OpenMappedExeConfiguration(ma p,
ConfigurationUserLevel.None);
_DllUserConfig =
ConfigurationManager.OpenMappedExeConfiguration(ma p,
ConfigurationUserLevel.PerUserRoaming);
}
Cheers,
Guy