System.Configuration.ConfigurationManager 8.0.1

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
FluentAssertions
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.5 and 4.7, as well as .NET Core 2.0, .NET Core 3.0, .NET Core 2.1, .NET Standard 1.3, 1.6, 2.0 and 2.1. Supports the unit test frameworks MSTest, MSTest2, Gallio, NUnit, XUnit, MBUnit, MSpec, and NSpec.
596
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.
78
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.
67
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.
67
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache 30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4.
66
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache When using NuGet 3.x this package requires at least version 3.4.
61
Microsoft.Data.SqlClient
Provides the data provider for SQL Server. These classes provide access to versions of SQL Server and encapsulate database-specific protocols, including tabular data stream (TDS) Commonly Used Types: Microsoft.Data.SqlClient.SqlConnection Microsoft.Data.SqlClient.SqlException Microsoft.Data.SqlClient.SqlParameter Microsoft.Data.SqlClient.SqlDataReader Microsoft.Data.SqlClient.SqlCommand Microsoft.Data.SqlClient.SqlTransaction Microsoft.Data.SqlClient.SqlParameterCollection Microsoft.Data.SqlClient.SqlClientFactory When using NuGet 3.x this package requires at least version 3.4.
57
Stripe.net
Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for the Stripe API. (Official Library)
57
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache When using NuGet 3.x this package requires at least version 3.4.
56
Stripe.net
Stripe.net is a sync/async .NET 4.5+ client, and a portable class library for the Stripe API. (Official Library)
54
Stripe.net
Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for the Stripe API. (Official Library)
53
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache When using NuGet 3.x this package requires at least version 3.4.
52
Microsoft.VisualStudio.Web.CodeGeneration.Utils
Contains utilities used by ASP.NET Core Code Generation packages.
51
Stripe.net
Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for the Stripe API. (Official Library)
51
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache
50
Microsoft.Data.SqlClient
Provides the data provider for SQL Server. These classes provide access to versions of SQL Server and encapsulate database-specific protocols, including tabular data stream (TDS) Commonly Used Types: Microsoft.Data.SqlClient.SqlConnection Microsoft.Data.SqlClient.SqlException Microsoft.Data.SqlClient.SqlParameter Microsoft.Data.SqlClient.SqlDataReader Microsoft.Data.SqlClient.SqlCommand Microsoft.Data.SqlClient.SqlTransaction Microsoft.Data.SqlClient.SqlParameterCollection Microsoft.Data.SqlClient.SqlClientFactory When using NuGet 3.x this package requires at least version 3.4.
49
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache When using NuGet 3.x this package requires at least version 3.4.
49
System.Runtime.Caching
Provides classes to use caching facilities. Commonly Used Types: System.Runtime.Caching.CacheEntryChangeMonitor System.Runtime.Caching.CacheEntryRemovedArguments System.Runtime.Caching.CacheEntryUpdateArguments System.Runtime.Caching.CacheItem System.Runtime.Caching.CacheItemPolicy System.Runtime.Caching.ChangeMonitor System.Runtime.Caching.FileChangeMonitor System.Runtime.Caching.HostFileChangeMonitor System.Runtime.Caching.MemoryCache System.Runtime.Caching.ObjectCache When using NuGet 3.x this package requires at least version 3.4.
48
Stripe.net
Stripe.net is a sync/async .NET 4.5+ client, and a portable class library for the Stripe API. (Official Library)
48

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

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