# ApplicationServicesContext.GetRequiredService&lt;T&gt; method

Returns the service, throwing InvalidOperationException when it is missing.

```csharp
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`](./Current.md) has not been set, or the service is not registered. |

## See Also

* class [ApplicationServicesContext](../ApplicationServicesContext.md)
* namespace [Eremex.AvaloniaUI.Controls.ApplicationServices](../index.md)

<!-- DO NOT EDIT: generated by xmldocmd for Eremex.Avalonia.Controls.ApplicationServices.dll -->
