© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
Trenyc

Properties of IConfigurationSection.Get are null?

I have a very simple test case set up using Microsoft.Extensions.Configuration and Microsoft.Extensions.Configuration.Binder. The config (aopsettings.json):

{
  "Foo": "bar"
}
{
  "Foo": "bar"
}

And the class:

public class Configuration
{
    public string Foo;
}
public class Configuration
{
    public string Foo;
}

The configuration builds correctly. I can see it contains the Foo property when debugging. However, when I try to use
var test = _configuration.Get<Configuration>()
var test = _configuration.Get<Configuration>()
, the Foo property of
test
test
is null.

I'm confused what is going wrong here. Can anyone spot the mistake?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Using IConfigurationSection.Get<T>() does not set properties with data from section
C#CC# / help
3y ago
✅ JsonSerializer - properties have null values
C#CC# / help
11mo ago
❔ Are these properties the same? `{ get => x; }` vs `{ get; } = x;`
C#CC# / help
4y ago
Are internal properties deserializable?
C#CC# / help
4mo ago