'IConfigurationSection' does not contain a definition for 'Get'

This morning I was working on an ASP.Net Core Controller that's housed in a .Net Core library project. I was wanting to load up some settings from a configuation file and ran into the following error message:

Error CS1061

    'IConfigurationSection' does not contain a definition for 'Get' and no accessible extension method 'Get' accepting a first argument of type 'IConfigurationSection' could be found (are you missing a using directive or an assembly reference?)

Normally the Intellisense in Visual Studio is good at recommending which NuGet package is missing but this morning it did not have one. After looking through the docuementation on Microsoft's site it appears that package I was looking for was Microsoft.Extensions.Configuration.Binder. After adding the NuGet package and then including a few using statements I was able to load my settings.

C# Usings

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Binder;

C# to load my settings

var settings = Configuration.GetSection("Settings").Get();

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.

Jay McCormick
Jay McCormick - Friday, April 1, 2022

I hit this exact thing today upgrading a .NETStandard v2 project to .NET Core v6. Much Obliged for your post.