Add values to app.config and retrieve them
Solution 1:
Are you missing the reference to System.Configuration.dll? ConfigurationManager
class lies there.
EDIT: The System.Configuration
namespace has classes in mscorlib.dll, system.dll and in system.configuration.dll. Your project always include the mscorlib.dll and system.dll references, but system.configuration.dll must be added to most project types, as it's not there by default...
Solution 2:
This works:
public static void AddValue(string key, string value)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
config.AppSettings.Settings.Add(key, value);
config.Save(ConfigurationSaveMode.Minimal);
}
Solution 3:
Try adding a Reference to System.Configuration
, you get some of the configuration namespace by referencing the System namespace, adding the reference to System.Configuration should allow you to access ConfigurationManager
.