J
Johnny Jörgensen
I don't get the ConfigurationManager object. All I want to do is store my
application settings and retrieve them on the next run.
I instantiate the Configuration:
static private Configuration m_Config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
I check if my setting exists:
try //kolla om Settings finns och skapa dem om de inte finns
{ string testSetting =
Utils.GlobalVars.FoBSettings.AppSettings.Settings["LokalServer"].Value; }
catch
{
m_Config.AppSettings.Settings.Add("LokalServer", "");
}
I change it if needed:
m_Config.AppSettings.Settings["LokalServer"].Value = "MyTestServer");
And I save the entire configuration file:
m_Config.Save(System.Configuration.ConfigurationSaveMode.Full);
Still, the next time I run the application, the LokalServer setting is Null
in AppSettings. Nothing is saved.
Why? What am I missing.
Cheers,
Johnny J.
application settings and retrieve them on the next run.
I instantiate the Configuration:
static private Configuration m_Config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
I check if my setting exists:
try //kolla om Settings finns och skapa dem om de inte finns
{ string testSetting =
Utils.GlobalVars.FoBSettings.AppSettings.Settings["LokalServer"].Value; }
catch
{
m_Config.AppSettings.Settings.Add("LokalServer", "");
}
I change it if needed:
m_Config.AppSettings.Settings["LokalServer"].Value = "MyTestServer");
And I save the entire configuration file:
m_Config.Save(System.Configuration.ConfigurationSaveMode.Full);
Still, the next time I run the application, the LokalServer setting is Null
in AppSettings. Nothing is saved.
Why? What am I missing.
Cheers,
Johnny J.