Microsoft.Extensions.Configuration.Binder 10.0.0-preview.6.25358.103

About

Provides the functionality to bind an object to data in configuration providers for Microsoft.Extensions.Configuration. This package enables you to represent the configuration data as strongly-typed classes defined in the application code. To bind a configuration, use the Microsoft.Extensions.Configuration.ConfigurationBinder.Get extension method on the IConfiguration object. To use this package, you also need to install a package for the configuration provider, for example, Microsoft.Extensions.Configuration.Json for the JSON provider.

The types contained in this assembly use Reflection at runtime which is not friendly with linking or AOT. To better support linking and AOT as well as provide more efficient strongly-typed binding methods - this package also provides a source generator. This generator is enabled by default when a project sets PublishAot but can also be enabled using <EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>.

Key Features

  • Configuring existing type instances from a configuration section (Bind)
  • Constructing new configured type instances from a configuration section (Get & GetValue)
  • Generating source to bind objects from a configuration section without a runtime reflection dependency.

How to Use

The following example shows how to bind a JSON configuration section to .NET objects.

using System;
using Microsoft.Extensions.Configuration;

class Settings
{
    public string Server { get; set; }
    public string Database { get; set; }
    public Endpoint[] Endpoints { get; set; }
}

class Endpoint
{
    public string IPAddress { get; set; }
    public int Port { get; set; }
}

class Program
{
    static void Main()
    {
        // Build a configuration object from JSON file
        IConfiguration config = new ConfigurationBuilder()
            .AddJsonFile("appsettings.json")
            .Build();

        // Bind a configuration section to an instance of Settings class
        Settings settings = config.GetSection("Settings").Get<Settings>();

        // Read simple values
        Console.WriteLine($"Server: {settings.Server}");
        Console.WriteLine($"Database: {settings.Database}");

        // Read nested objects
        Console.WriteLine("Endpoints: ");

        foreach (Endpoint endpoint in settings.Endpoints)
        {
            Console.WriteLine($"{endpoint.IPAddress}:{endpoint.Port}");
        }
    }
}

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

{
  "Settings": {
    "Server": "example.com",
    "Database": "Northwind",
    "Endpoints": [
      {
        "IPAddress": "192.168.0.1",
        "Port": "80"
      },
      {
        "IPAddress": "192.168.10.1",
        "Port": "8080"
      }
    ]
  }
}

You can include a configuration file using a code like this in your .csproj file:

<ItemGroup>
  <Content Include="appsettings.json">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
</ItemGroup>

You can add the following property to enable the source generator. This requires a .NET 8.0 SDK or later.

<PropertyGroup>
  <EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>

Main Types

The main types provided by this library are:

  • Microsoft.Extensions.Configuration.ConfigurationBinder
  • Microsoft.Extensions.Configuration.BinderOptions

Additional Documentation

Feedback & Contributing

Microsoft.Extensions.Configuration.Binder 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 Microsoft.Extensions.Configuration.Binder.

Packages Downloads
Microsoft.Extensions.Logging.Configuration
Configuration support for Microsoft.Extensions.Logging.
4,922
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
4,919
Serilog.Settings.Configuration
Microsoft.Extensions.Configuration (appsettings.json) support for Serilog.
4,877
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
2,246
Microsoft.Extensions.Logging.Configuration
Configuration support for Microsoft.Extensions.Logging.
2,231
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
2,223
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
2,216
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
2,206
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
511
Serilog.Settings.Configuration
Microsoft.Extensions.Configuration (appsettings.json) support for Serilog.
511
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
506
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
92
Microsoft.Extensions.OptionsModel
Provides a strongly typed way of specifying and accessing settings using dependency injection.
86
Microsoft.AspNetCore.Server.Kestrel.Core
Core components of ASP.NET Core Kestrel cross-platform web server.
72
Sentry.AspNetCore
Official ASP.NET Core integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.
71
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
70
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications. When using NuGet 3.x this package requires at least version 3.4.
70
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
70
Microsoft.AspNetCore.Server.Kestrel.Core
Core components of ASP.NET Core Kestrel cross-platform web server.
68
Microsoft.AspNetCore.Components.WebAssembly
Build client-side single-page applications (SPAs) with Blazor running under WebAssembly. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/fb4b5a21ebd67b31fff4ddf5c039181da504c932
66

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

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
10.0.0-rc.1.25451.107 4 09/11/2025
10.0.0-preview.7.25380.108 6 08/14/2025
10.0.0-preview.6.25358.103 10 07/17/2025
10.0.0-preview.5.25277.114 12 06/14/2025
10.0.0-preview.4.25258.110 15 05/15/2025
10.0.0-preview.3.25171.5 21 04/11/2025
10.0.0-preview.2.25163.2 18 03/26/2025
10.0.0-preview.1.25080.5 20 02/26/2025
9.0.9 3 09/12/2025
9.0.8 8 08/07/2025
9.0.7 8 07/10/2025
9.0.6 11 06/13/2025
9.0.5 13 05/15/2025
9.0.4 16 04/12/2025
9.0.3 18 03/12/2025
9.0.2 21 02/12/2025
9.0.1 21 01/22/2025
9.0.0 46 11/13/2024
9.0.0-rc.2.24473.5 26 10/12/2024
9.0.0-rc.1.24431.7 37 09/16/2024
9.0.0-preview.7.24405.7 31 08/13/2024
9.0.0-preview.6.24327.7 37 07/10/2024
9.0.0-preview.5.24306.7 40 06/11/2024
9.0.0-preview.4.24266.19 33 05/26/2024
9.0.0-preview.3.24172.9 45 04/12/2024
9.0.0-preview.2.24128.5 48 03/14/2024
9.0.0-preview.1.24080.9 39 02/23/2024
8.0.2 3,022 07/10/2024
8.0.1 1,966 01/17/2024
8.0.0 4,920 11/17/2023
8.0.0-rc.2.23479.6 52 10/10/2023
8.0.0-rc.1.23419.4 62 09/14/2023
8.0.0-preview.7.23375.6 51 08/30/2023
8.0.0-preview.6.23329.7 56 07/11/2023
8.0.0-preview.5.23280.8 61 06/28/2023
8.0.0-preview.4.23259.5 59 05/20/2023
8.0.0-preview.3.23174.8 52 04/30/2023
8.0.0-preview.2.23128.3 61 04/30/2023
8.0.0-preview.1.23110.8 57 02/22/2023
7.0.4 514 04/30/2023
7.0.3 59 05/14/2023
7.0.2 71 01/24/2023
7.0.1 73 12/27/2022
7.0.0 523 12/07/2022
7.0.0-rc.2.22472.3 62 06/28/2023
7.0.0-rc.1.22426.10 71 10/26/2022
7.0.0-preview.7.22375.6 58 10/30/2022
7.0.0-preview.6.22324.4 56 10/16/2022
7.0.0-preview.5.22301.12 60 06/27/2023
7.0.0-preview.4.22229.4 48 06/30/2023
7.0.0-preview.3.22175.4 52 07/04/2023
7.0.0-preview.2.22152.2 62 06/29/2023
7.0.0-preview.1.22076.8 52 06/29/2023
6.0.2-mauipre.1.22102.15 73 05/27/2022
6.0.2-mauipre.1.22054.8 50 06/29/2023
6.0.1 28 11/13/2024
6.0.0 2,236 12/07/2021
6.0.0-rc.2.21480.5 59 06/26/2023
6.0.0-rc.1.21451.13 54 06/28/2023
6.0.0-preview.7.21377.19 62 05/27/2022
6.0.0-preview.6.21352.12 56 07/02/2023
6.0.0-preview.5.21301.5 54 06/29/2023
6.0.0-preview.4.21253.7 47 06/29/2023
6.0.0-preview.3.21201.4 52 05/27/2022
6.0.0-preview.2.21154.6 55 05/27/2022
6.0.0-preview.1.21102.12 68 08/10/2022
5.0.0 72 05/26/2022
5.0.0-rc.2.20475.5 50 06/16/2023
5.0.0-rc.1.20451.14 67 12/02/2022
5.0.0-preview.8.20407.11 52 07/02/2023
5.0.0-preview.7.20364.11 55 05/27/2022
5.0.0-preview.6.20305.6 62 06/28/2023
5.0.0-preview.5.20278.1 51 05/27/2022
5.0.0-preview.4.20251.6 52 05/27/2022
5.0.0-preview.3.20215.2 59 05/27/2022
5.0.0-preview.2.20160.3 56 06/30/2023
5.0.0-preview.1.20120.4 62 05/27/2022
3.1.32 48 05/05/2023
3.1.31 53 05/10/2023
3.1.30 58 04/22/2023
3.1.29 53 04/21/2023
3.1.28 51 05/02/2023
3.1.27 70 11/27/2022
3.1.26 55 03/21/2023
3.1.25 58 05/28/2022
3.1.24 54 05/27/2022
3.1.23 58 03/15/2023
3.1.22 51 03/22/2023
3.1.21 57 05/28/2022
3.1.20 52 03/22/2023
3.1.19 54 05/17/2023
3.1.18 55 11/04/2022
3.1.17 51 04/19/2023
3.1.16 61 11/02/2022
3.1.15 75 05/27/2022
3.1.14 47 03/30/2023
3.1.13 56 04/10/2023
3.1.12 56 09/24/2022
3.1.11 57 06/11/2022
3.1.10 48 02/19/2023
3.1.9 55 03/28/2023
3.1.8 59 05/27/2022
3.1.7 56 11/09/2020
3.1.6 56 05/22/2023
3.1.5 66 03/31/2023
3.1.4 57 04/09/2023
3.1.3 69 02/25/2023
3.1.2 66 05/27/2022
3.1.1 69 06/30/2023
3.1.0 516 07/11/2022
3.1.0-preview3.19553.2 55 05/27/2022
3.1.0-preview2.19525.4 55 05/27/2022
3.1.0-preview1.19506.1 52 06/27/2023
3.0.3 65 06/07/2023
3.0.2 56 05/27/2022
3.0.1 61 05/03/2023
3.0.0 54 12/31/2022
3.0.0-rc1.19456.10 65 05/27/2022
3.0.0-preview9.19423.4 55 05/27/2022
3.0.0-preview8.19405.4 61 06/30/2023
3.0.0-preview7.19362.4 59 04/11/2023
3.0.0-preview6.19304.6 58 10/23/2022
3.0.0-preview5.19227.9 56 11/08/2022
3.0.0-preview4.19216.2 68 05/28/2022
3.0.0-preview3.19153.1 54 05/27/2022
3.0.0-preview.19074.2 56 06/27/2023
3.0.0-preview.18572.1 53 05/27/2022
2.2.4 61 05/27/2022
2.2.0 78 09/21/2022
2.2.0-preview3-35497 58 04/10/2023
2.2.0-preview2-35157 68 05/27/2022
2.2.0-preview1-35029 49 05/27/2022
2.1.10 57 08/24/2022
2.1.1 2,200 05/27/2022
2.1.0 62 05/27/2022
2.1.0-rc1-final 72 05/27/2022
2.1.0-preview2-final 59 10/29/2022
2.1.0-preview1-final 62 05/27/2022
2.0.2 54 05/27/2022
2.0.1 58 11/25/2022
2.0.0 55 06/07/2022
2.0.0-preview2-final 55 04/05/2023
2.0.0-preview1-final 61 03/29/2023
1.1.2 69 11/12/2022
1.1.1 70 12/13/2021
1.1.0 53 04/20/2023
1.1.0-preview1-final 67 05/27/2022
1.0.2 56 12/24/2021
1.0.1 53 11/15/2022
1.0.0 50 06/26/2023
1.0.0-rc2-final 61 11/27/2022
1.0.0-rc1-final 61 05/27/2022