Share via


ServiceManager.GetRequiredService<TServiceType> Method

Retrieves an instance of a service of the specified type.

Namespace:  Microsoft.Windows.Design
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Syntax

'Declaration
Public Function GetRequiredService(Of TServiceType) As TServiceType
public TServiceType GetRequiredService<TServiceType>()
public:
generic<typename TServiceType>
TServiceType GetRequiredService()
member GetRequiredService : unit -> 'TServiceType 
JScript does not support generic types or methods.

Type Parameters

  • TServiceType

Return Value

Type: TServiceType
An instance of the type of service requested. This method never returns nulla null reference (Nothing in Visual Basic).

Exceptions

Exception Condition
NotSupportedException

There is no service of the type requested.

Remarks

GetRequiredService<TServiceType> throws a NotSupportedException if a service of the type requested is not available. If nulla null reference (Nothing in Visual Basic) is acceptable as a return value in place of an exception, use GetService instead. GetRequiredService<TServiceType> provides a more reliable contract.

.NET Framework Security

See Also

Reference

ServiceManager Class

Microsoft.Windows.Design Namespace

EditingContext

ContextItem

Other Resources

WPF Designer Extensibility