ServiceProviderExtensions.GetRequiredService<TService> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the required service of type TService from the IServiceProvider.
public static TService GetRequiredService<TService>(this IServiceProvider provider);
static member GetRequiredService : IServiceProvider -> 'Service
<Extension()>
Public Function GetRequiredService(Of TService) (provider As IServiceProvider) As TService
Type Parameters
- TService
The type of the service.
Parameters
- provider
- IServiceProvider
The service provider.
Returns
The required service of type TService.
Exceptions
Thrown when the provider is null.
Thrown when the required service is not found.