tomopk.blogg.se

Microsoft configuration manager
Microsoft configuration manager












microsoft configuration manager

Read and write configuration files as a whole. These members perform read-only operations, use a single cached instance of the configuration, and are multithread aware. For some sections such as appSettings and connectionStrings, use the AppSettings and ConnectionStrings classes. To access configuration information, call the GetSection method. Read a section from a configuration file. The ConfigurationManager class includes members that enable you to perform the following tasks: By using these types, you can work directly with configuration information and you can extend configuration files to include custom information. You can use the built-in System.Configuration types or derive from them to handle configuration information. For more information, see Configuring Apps by using Configuration Files.

microsoft configuration manager

The name and location of the application configuration file depend on the application's host. By default, some project templates, like Console Application, do not reference this assembly so you must manually reference it. To use the ConfigurationManager class, your project must reference the System.Configuration assembly.

microsoft configuration manager microsoft configuration manager

For web applications, use the WebConfigurationManager class. This class replaces the ConfigurationSettings class, which is deprecated. The ConfigurationManager class enables you to access machine, application, and user configuration information. The previous example assumes your project has an App.config as shown below. Var appSettings = ConfigurationManager.AppSettings Ĭonsole.WriteLine("AppSettings is empty.") Ĭonsole.WriteLine("Key: ", reader(0), reader(1))) using System ĪddUpdateAppSettings("NewSetting", "May 7, 2014") ĪddUpdateAppSettings("Setting1", "May 8, 2014") The first example shows a simple console application that reads application settings, adds a new setting, and updates an existing setting.














Microsoft configuration manager