Skip to content

ApplicationServicesContext.GetRequiredService<T> method

Returns the service, throwing InvalidOperationException when it is missing.

public static T GetRequiredService<T>()
    where T : class
parameter description
T The service type to resolve, normally an interface.

Return Value

The registered service instance. Never null.

Exceptions

exception condition
InvalidOperationException Current has not been set, or the service is not registered.

See Also