Ioc.GetRequiredService<T> Method

Definition

Resolves an instance of a specified service type.

public T GetRequiredService<T> () where T : class;
member this.GetRequiredService : unit -> 'T (requires 'T : null)
Public Function GetRequiredService(Of T As Class) () As T

Type Parameters

T

The type of service to resolve.

Returns

T

An instance of the specified service, or null.

Exceptions

Throw if the current Ioc instance has not been initialized, or if the requested service type was not registered in the service provider currently in use.

Applies to