❔ Exception while using .BindConfiguration instead of .Configure
Hello !
I need some help to understand why I get an while I am using Option Pattern (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-7.0) with dependency injection.
The exception :
My tests are using a custom helper which iterate through a IServiceCollection to retrieve service from default IoC by using IServiceProvider.GetService( ServiceDescriptor.ServiceType).
At the beginning I was registering my options this way (which cause the exception spoken above) :
I changed the registration for this way (which work perfect) :
The difference on the code from .BindConfiguration and .Configure :
- .BindConfiguration use this instruction:
-.Configure use this instructio :
Can someone explain the difference and why the first one throw an exception please ?
Thank you
Options pattern in ASP.NET Core
Discover how to use the options pattern to represent groups of related settings in ASP.NET Core apps.
3 Replies
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Hi, someon can up ? thanks !
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.