ServiceProviderExtensions.GetService<TService>(IServiceProvider) 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 service of type TService from the IServiceProvider.
public static TService? GetService<TService>(this IServiceProvider provider) where TService : class;
static member GetService : IServiceProvider -> 'Service (requires 'Service : null)
<Extension()>
Public Function GetService(Of TService As Class) (provider As IServiceProvider) As TService
Type Parameters
- TService
The type of the service.
Parameters
- provider
- IServiceProvider
The service provider.
Returns
The service of type TService or null if not found.
Exceptions
Thrown when the provider is null.