i'm trying to test some functionality which is dependant on a configuration value (if Settings["foo"]
= true than return 5, otherwise- return -1).
So what I'm trying to do is to change the configuration value at runtime.
my config file looks like so (simplified):
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="DomainSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<DomainSettings>
<setting name="foo" serializeAs="String">
<value>false</value>
</setting>
</ICTS.SmartQueue.Domain.DomainSettings>
</applicationSettings>
and I'm doing the following:
//get config file
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//get relevant section
var section = (ClientSettingsSection)config.GetSection("applicationSettings/DomainSettings");
//get element from section
var element = section.Settings.Get("Foo");
//change its value and save it
element.Value.ValueXml.InnerText = true.ToString();
config.Save(System.Configuration.ConfigurationSaveMode.Modified, true);
//force refresh
ConfigurationManager.RefreshSection("applicationSettings/DomainSettings");
I can see that the value is actually changed when I look at the test's config file in the 'Out' directory (MyTests.DLL.config).
However, DomainSettings.Default.Foo
still evaluates to 'false'.
any ideas?