service provider
The built dependency injection container, which creates and hands out services according to their registrations.
In more detail
GetRequiredService<T>() throws immediately if nothing is registered, so wiring mistakes fail early instead of returning null. In a web app the host builds the provider; you rarely call it yourself.
Related terms
- IServiceCollection — The list of service registrations the dependency injection container is built from, reached in ASP.NET Core as builder.Services.
- service locator — An anti-pattern in which code asks a global container for its dependencies at the point of use instead of receiving them in its constructor.
- dependency injection — Giving an object the collaborators it needs from outside, usually through its constructor, instead of letting it create or look them up itself.
Taught in
- The Dependency Injection Container: Scopes and Lifetimes — Modern .NET Core, C# & Enterprise Microservices