System.Configuration.ConfigurationManager 9.0.0

About

Provides types that support using XML configuration files (app.config). This package exists only to support migrating existing .NET Framework code that already uses System.Configuration. When writing new code, use another configuration system instead, such as Microsoft.Extensions.Configuration.

How to Use

The following example shows how to read and modify the application configuration settings.

using System;
using System.Configuration;

class Program
{
    static void Main()
    {
        try
        {
            // Open current application configuration
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            KeyValueConfigurationCollection section = config.AppSettings.Settings;

            // Print settings from configuration file
            foreach (string key in section.AllKeys)
            {
                Console.WriteLine($"{key}: {section[key].Value}");
            }

            // Add new setting
            section.Add("Database", "TestDatabase");

            // Change existing setting
            section["Username"].Value = "TestUser";

            // Save changes to file
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name);
        }
        catch (ConfigurationErrorsException ex)
        {
            Console.WriteLine("Error reading configuration: ");
            Console.WriteLine(ex.Message);
        }
    }
}

To run this example, include an app.config file with the following content in your project:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Server" value="example.com"/>
    <add key="Username" value="Admin"/>
  </appSettings>
</configuration>

Main Types

The main types provided by this library are:

  • System.Configuration.Configuration
  • System.Configuration.ConfigurationManager

Additional Documentation

Feedback & Contributing

System.Configuration.ConfigurationManager is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on System.Configuration.ConfigurationManager.

Packages Downloads
System.Diagnostics.PerformanceCounter
Provides the System.Diagnostics.PerformanceCounter class, which allows access to Windows performance counters. Commonly Used Types: System.Diagnostics.PerformanceCounter When using NuGet 3.x this package requires at least version 3.4.
7,074
System.Diagnostics.PerformanceCounter
Provides the System.Diagnostics.PerformanceCounter class, which allows access to Windows performance counters. Commonly Used Types: System.Diagnostics.PerformanceCounter When using NuGet 3.x this package requires at least version 3.4.
4,784
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
2,000
NPOI
.NET port of Apache POI | Contact us on telegram: https://t.me/npoidevs
1,954
NPOI
.NET port of Apache POI | Contact us on telegram: https://t.me/npoidevs
1,911
System.Diagnostics.PerformanceCounter
Provides the System.Diagnostics.PerformanceCounter class, which allows access to Windows performance counters. Commonly Used Types: System.Diagnostics.PerformanceCounter 30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4.
1,004
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
909
Microsoft.CodeAnalysis.Elfie
An extensible library for fast indexing of code artifacts.
906
Microsoft.VisualStudio.Web.CodeGeneration.Design
Code Generation tool for ASP.NET Core. Contains the dotnet-aspnet-codegenerator command used for generating controllers and views.
826
Microsoft.DotNet.Scaffolding.Shared
Contains interfaces for Project Model and messaging for scaffolding.
816
Microsoft.VisualStudio.Web.CodeGenerators.Mvc
Code Generators for ASP.NET Core MVC. Contains code generators for MVC Controllers and Views.
809
Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
Contains Entity Framework Core Services used by ASP.NET Core Code Generators.
807
Microsoft.VisualStudio.Web.CodeGeneration.Core
Contains the core infrastructure used by ASP.NET Core Code Generators.
806
Microsoft.VisualStudio.Web.CodeGeneration
Contains the CodeGenCommand that finds the appropriate code generator and invokes it from project dependencies.
804
Microsoft.VisualStudio.Web.CodeGeneration.Templating
Contains Razor based templating host used by ASP.NET Core Code Generators.
799
Microsoft.VisualStudio.Web.CodeGeneration.Utils
Contains utilities used by ASP.NET Core Code Generation packages.
799
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
776
Microsoft.DotNet.Scaffolding.Shared
Contains interfaces for Project Model and messaging for scaffolding.
603
Microsoft.VisualStudio.Web.CodeGeneration
Contains the CodeGenCommand that finds the appropriate code generator and invokes it from project dependencies.
603
Microsoft.VisualStudio.Web.CodeGeneration.Design
Code Generation tool for ASP.NET Core. Contains the dotnet-aspnet-codegenerator command used for generating controllers and views.
602

https://go.microsoft.com/fwlink/?LinkID=799421

Version Downloads Last updated
9.0.0 8 11/13/2024
9.0.0-rc.2.24473.5 5 10/22/2024
9.0.0-rc.1.24431.7 9 09/12/2024
9.0.0-preview.7.24405.7 7 08/17/2024
9.0.0-preview.6.24327.7 12 07/12/2024
9.0.0-preview.5.24306.7 9 06/20/2024
9.0.0-preview.4.24266.19 10 05/25/2024
9.0.0-preview.3.24172.9 14 04/20/2024
9.0.0-preview.2.24128.5 13 03/13/2024
9.0.0-preview.1.24080.9 17 02/26/2024
8.0.1 5 10/14/2024
8.0.0 152 12/13/2023
8.0.0-rc.2.23479.6 13 12/27/2023
8.0.0-rc.1.23419.4 18 10/02/2023
8.0.0-preview.7.23375.6 17 08/21/2023
8.0.0-preview.6.23329.7 16 10/14/2023
8.0.0-preview.5.23280.8 16 09/28/2023
8.0.0-preview.4.23259.5 16 05/31/2023
8.0.0-preview.3.23174.8 17 07/04/2023
8.0.0-preview.2.23128.3 19 07/04/2023
8.0.0-preview.1.23110.8 15 07/05/2023
7.0.0 799 07/05/2023
7.0.0-rc.2.22472.3 15 09/27/2023
7.0.0-rc.1.22426.10 19 06/08/2023
7.0.0-preview.7.22375.6 17 09/14/2023
7.0.0-preview.6.22324.4 13 12/24/2023
7.0.0-preview.5.22301.12 14 01/29/2024
7.0.0-preview.4.22229.4 15 12/24/2023
7.0.0-preview.3.22175.4 12 10/12/2023
7.0.0-preview.2.22152.2 13 11/11/2023
7.0.0-preview.1.22076.8 14 10/17/2023
6.0.2 6 11/13/2024
6.0.2-mauipre.1.22102.15 17 12/29/2023
6.0.2-mauipre.1.22054.8 12 06/07/2023
6.0.1 38 07/04/2023
6.0.0 2,031 06/16/2022
6.0.0-rc.2.21480.5 18 07/06/2023
6.0.0-rc.1.21451.13 16 10/12/2023
6.0.0-preview.7.21377.19 11 02/27/2024
6.0.0-preview.6.21352.12 16 11/10/2023
6.0.0-preview.5.21301.5 17 10/10/2023
6.0.0-preview.4.21253.7 15 06/08/2023
6.0.0-preview.3.21201.4 16 09/18/2023
6.0.0-preview.2.21154.6 18 10/26/2023
6.0.0-preview.1.21102.12 13 06/20/2023
5.0.0 4,765 03/13/2021
5.0.0-rc.2.20475.5 16 10/22/2023
5.0.0-rc.1.20451.14 12 12/25/2023
5.0.0-preview.8.20407.11 14 06/19/2023
5.0.0-preview.7.20364.11 15 12/31/2023
5.0.0-preview.6.20305.6 15 07/05/2023
5.0.0-preview.5.20278.1 16 12/25/2023
5.0.0-preview.4.20251.6 16 12/21/2023
5.0.0-preview.3.20214.6 15 06/20/2023
5.0.0-preview.2.20160.6 14 06/09/2023
5.0.0-preview.1.20120.5 14 10/30/2023
4.7.0 7,052 12/16/2020
4.7.0-preview3.19551.4 13 12/24/2023
4.7.0-preview2.19523.17 12 10/17/2023
4.7.0-preview1.19504.10 17 12/06/2023
4.6.0 12 06/12/2023
4.6.0-rc1.19456.4 11 12/26/2023
4.6.0-preview9.19421.4 17 12/31/2023
4.6.0-preview9.19416.11 14 12/10/2023
4.6.0-preview8.19405.3 17 07/11/2023
4.6.0-preview7.19362.9 14 11/04/2023
4.6.0-preview6.19303.8 15 11/20/2023
4.6.0-preview6.19264.9 16 12/31/2023
4.6.0-preview5.19224.8 12 02/26/2024
4.6.0-preview4.19212.13 15 10/10/2023
4.6.0-preview3.19128.7 14 12/30/2023
4.6.0-preview.19073.11 14 10/18/2023
4.6.0-preview.18571.3 15 01/01/2024
4.5.0 5,509 12/16/2020
4.5.0-rc1 11 03/11/2024
4.5.0-preview2-26406-04 17 12/26/2023
4.5.0-preview1-26216-02 15 10/26/2023
4.5.0-preview1-25914-04 13 12/29/2023
4.4.1 300 01/28/2021
4.4.0 12 12/18/2023
4.4.0-preview2-25405-01 15 01/07/2024
4.4.0-preview1-25305-02 14 12/26/2023