System.Configuration; How to change app.config at runtime in debugmode.

B

bls

Hi,
I want to change an app.comfig connection string at runtime (in debug mode)

This does at least not work ...

Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

// Add an Application Setting.
config.AppSettings.Settings.Remove("FirebirdConn");
config.AppSettings.Settings.Add("FirebirdConn",
csb.ToString());
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
//ConfigurationManager.RefreshSection("connectionStrings");


Any ideas ???
Thanks in advance,
Bjoern
 
A

Arne Vajhøj

I want to change an app.comfig connection string at runtime (in debug mode)

This does at least not work ...

Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

// Add an Application Setting.
config.AppSettings.Settings.Remove("FirebirdConn");
config.AppSettings.Settings.Add("FirebirdConn", csb.ToString());
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
//ConfigurationManager.RefreshSection("connectionStrings");

Any ideas ???

Please define "not work".

Arne
 
A

Arne Vajhøj

Project / MyProject Properties / Seeting Tab don't show the modified
connection string.

But that is within the IDE.

Is the file in the bin dir changed?

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top