Just got VS2005, and I am trying to use the included methods for adding keys to the app.config file. Here is my code:
System.Configuration.
Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);AppSection.Settings.Add (
new KeyValueConfigurationElement ( "NEW", "Something"));config.AppSettings.Settings.Add(
new KeyValueConfigurationElement(""NEW", "Something"));config.Save();
it runs, but does nothing. the Keys are not added. No errors of any sort. Any ideas

adding KEYS to App.Config in VS 2005
carzyR
ocanon
Try disabling the Visual Studio hosting process to keep the vshost from starting and overwriting your file. From your project properties, choose the Debug tab and you should find the checkbox at the bottom of the list.
Just for note though, there are benefits of the vshost, take a look at this blog entry (http://blogs.msdn.com/dtemp/archive/2004/08/17/215764.aspx) for some info on what they are and why they can be useful.
I hope that this solves your problem.
RSatter
I sure hope what you've got there doesn't run... AppSection.Settings no longer exists if I am not mistaken, and never used for the WinForms .config file.
Let me guess though... you are executing the program in the IDE From the looks of it, as soon as Save() is called the config file is updated... only it gets whiped out with your default app.config file after closing. Correct
The reason for this would be because the vshost wrapper reloads, and in doing so takes your default app.config file specified in the project and overwrites the one in your build destination, causing you to loose those settings you wrong.
Does this make sense
See http://msdn2.microsoft.com/en-us/library/system.configuration.appsettingssection.aspx for more info on writing to your config file.
Freek Bos