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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Windows.Design Namespace