Microsoft.Extensions.Configuration.Binder 9.0.0-preview.1.24080.9

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
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
67
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
75
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
77
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
78
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
166
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
278
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
305
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
408
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
763
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
1,198
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging.
3,419
Microsoft.Extensions.Logging
Logging infrastructure default implementation for Microsoft.Extensions.Logging. This package was built from the source code at https://github.com/aspnet/Extensions/tree/9bc79b2f25a3724376d7af19617c33749a30ea3a
66
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
62
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
72
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
84
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
278
Microsoft.Extensions.Options.ConfigurationExtensions
Provides additional configuration specific functionality related to Options.
1,311
Microsoft.FeatureManagement
Microsoft.FeatureManagement provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common .NET code patterns to make exposing these features possible.
63
Microsoft.FeatureManagement
Microsoft.FeatureManagement provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common .NET code patterns to make exposing these features possible.
68

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

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

.NET Standard 2.0

Version Downloads Last updated
10.0.0-preview.6.25358.103 1 07/17/2025
10.0.0-preview.5.25277.114 8 06/08/2025
10.0.0-preview.4.25258.110 9 05/15/2025
10.0.0-preview.3.25171.5 11 04/16/2025
10.0.0-preview.2.25163.2 11 03/26/2025
10.0.0-preview.1.25080.5 13 03/06/2025
9.0.7 0 07/08/2025
9.0.6 6 06/12/2025
9.0.5 7 05/15/2025
9.0.4 8 04/16/2025
9.0.3 13 03/14/2025
9.0.2 14 02/22/2025
9.0.1 16 01/19/2025
9.0.0 18 11/17/2024
9.0.0-rc.2.24473.5 17 10/08/2024
9.0.0-rc.1.24431.7 17 09/13/2024
9.0.0-preview.7.24405.7 16 08/14/2024
9.0.0-preview.6.24327.7 19 07/12/2024
9.0.0-preview.5.24306.7 15 06/13/2024
9.0.0-preview.4.24266.19 16 05/27/2024
9.0.0-preview.3.24172.9 28 04/14/2024
9.0.0-preview.2.24128.5 18 03/13/2024
9.0.0-preview.1.24080.9 19 02/15/2024
8.0.2 17 07/12/2024
8.0.1 21 02/12/2024
8.0.0 25 02/10/2024
8.0.0-rc.2.23479.6 20 12/26/2023
8.0.0-rc.1.23419.4 17 02/12/2024
8.0.0-preview.7.23375.6 22 02/12/2024
8.0.0-preview.6.23329.7 18 02/12/2024
8.0.0-preview.5.23280.8 19 02/12/2024
8.0.0-preview.4.23259.5 21 02/12/2024
8.0.0-preview.3.23174.8 25 02/12/2024
8.0.0-preview.2.23128.3 20 02/12/2024
8.0.0-preview.1.23110.8 32 02/12/2024
7.0.4 24 02/12/2024
7.0.3 25 04/21/2023
7.0.2 21 02/12/2024
7.0.1 24 01/26/2024
7.0.0 22 02/12/2024
7.0.0-rc.2.22472.3 20 01/20/2024
7.0.0-rc.1.22426.10 21 02/12/2024
7.0.0-preview.7.22375.6 23 02/12/2024
7.0.0-preview.6.22324.4 23 02/12/2024
7.0.0-preview.5.22301.12 19 02/12/2024
7.0.0-preview.4.22229.4 28 02/12/2024
7.0.0-preview.3.22175.4 17 02/12/2024
7.0.0-preview.2.22152.2 19 02/12/2024
7.0.0-preview.1.22076.8 19 02/12/2024
6.0.2-mauipre.1.22102.15 20 02/12/2024
6.0.2-mauipre.1.22054.8 20 02/12/2024
6.0.1 14 11/17/2024
6.0.0 125 12/08/2021
6.0.0-rc.2.21480.5 18 02/12/2024
6.0.0-rc.1.21451.13 20 02/12/2024
6.0.0-preview.7.21377.19 20 02/12/2024
6.0.0-preview.6.21352.12 19 02/12/2024
6.0.0-preview.5.21301.5 18 02/12/2024
6.0.0-preview.4.21253.7 19 02/12/2024
6.0.0-preview.3.21201.4 19 02/12/2024
6.0.0-preview.2.21154.6 20 02/12/2024
6.0.0-preview.1.21102.12 17 02/12/2024
5.0.0 26 11/12/2020
5.0.0-rc.2.20475.5 19 02/12/2024
5.0.0-rc.1.20451.14 20 02/12/2024
5.0.0-preview.8.20407.11 22 02/12/2024
5.0.0-preview.7.20364.11 20 02/12/2024
5.0.0-preview.6.20305.6 19 02/12/2024
5.0.0-preview.5.20278.1 20 02/12/2024
5.0.0-preview.4.20251.6 22 02/12/2024
5.0.0-preview.3.20215.2 21 01/14/2024
5.0.0-preview.2.20160.3 18 02/12/2024
5.0.0-preview.1.20120.4 18 02/12/2024
3.1.32 20 02/12/2024
3.1.31 17 02/12/2024
3.1.30 19 02/12/2024
3.1.29 17 02/12/2024
3.1.28 19 02/12/2024
3.1.27 23 02/12/2024
3.1.26 22 02/12/2024
3.1.25 20 02/12/2024
3.1.24 20 02/12/2024
3.1.23 19 01/06/2024
3.1.22 76 12/14/2021
3.1.21 18 02/12/2024
3.1.20 19 02/12/2024
3.1.19 23 01/04/2022
3.1.18 82 12/14/2021
3.1.17 34 07/13/2021
3.1.16 24 06/08/2021
3.1.15 20 05/11/2021
3.1.14 22 04/06/2021
3.1.13 72 03/09/2021
3.1.12 74 02/09/2021
3.1.11 34 01/25/2021
3.1.10 26 11/10/2020
3.1.9 158 10/25/2020
3.1.8 423 09/11/2020
3.1.7 21 08/24/2020
3.1.6 316 08/04/2020
3.1.5 33 06/09/2020
3.1.4 24 02/12/2024
3.1.3 21 03/28/2020
3.1.2 725 02/27/2020
3.1.1 21 02/10/2020
3.1.0 275 02/10/2020
3.1.0-preview3.19553.2 19 12/23/2023
3.1.0-preview2.19525.4 19 02/12/2024
3.1.0-preview1.19506.1 22 06/23/2021
3.0.3 23 03/15/2023
3.0.2 19 01/01/2024
3.0.1 19 02/10/2024
3.0.0 75 02/11/2020
3.0.0-rc1.19456.10 20 02/12/2024
3.0.0-preview9.19423.4 18 02/12/2024
3.0.0-preview8.19405.4 16 02/10/2024
3.0.0-preview7.19362.4 18 02/12/2024
3.0.0-preview6.19304.6 17 02/12/2024
3.0.0-preview5.19227.9 23 02/12/2024
3.0.0-preview4.19216.2 19 02/12/2024
3.0.0-preview3.19153.1 19 02/10/2024
3.0.0-preview.19074.2 17 02/12/2024
3.0.0-preview.18572.1 16 02/12/2024
2.2.4 21 02/10/2024
2.2.0 71 06/23/2020
2.2.0-preview3-35497 19 02/12/2024
2.2.0-preview2-35157 20 02/12/2024
2.2.0-preview1-35029 17 02/12/2024
2.1.10 124 03/24/2021
2.1.1 2,828 07/05/2020
2.1.0 1,195 02/11/2020
2.1.0-rc1-final 23 02/12/2024
2.1.0-preview2-final 21 02/12/2024
2.1.0-preview1-final 19 02/12/2024
2.0.2 22 02/12/2024
2.0.1 21 02/12/2024
2.0.0 1,985 02/10/2020
2.0.0-preview2-final 21 01/08/2024
2.0.0-preview1-final 24 12/29/2023
1.1.2 19 02/10/2020
1.1.1 19 02/10/2024
1.1.0 19 02/12/2024
1.1.0-preview1-final 19 01/21/2024
1.0.2 22 02/10/2024
1.0.1 23 12/04/2023
1.0.0 22 02/10/2024
1.0.0-rc2-final 21 02/12/2024
1.0.0-rc1-final 24 02/12/2024