Share via


Kernel.GetRequiredService<T>(Object) Method

Definition

Gets a required service from the Services provider.

public T GetRequiredService<T> (object? serviceKey = default) where T : class;
member this.GetRequiredService : obj -> 'T (requires 'T : null)
Public Function GetRequiredService(Of T As Class) (Optional serviceKey As Object = Nothing) As T

Type Parameters

T

Specifies the type of the service to get.

Parameters

serviceKey
Object

An object that specifies the key of the service to get.

Returns

T

The found service instance.

Exceptions

A service of the specified type and name could not be found.

Applies to