次の方法で共有


ServiceManager.GetRequiredService<TServiceType> メソッド

指定された型のサービスのインスタンスを取得します。

名前空間:  Microsoft.Windows.Design
アセンブリ:  Microsoft.Windows.Design.Extensibility (Microsoft.Windows.Design.Extensibility.dll 内)

構文

'宣言
Public Function GetRequiredService(Of TServiceType) As TServiceType
public TServiceType GetRequiredService<TServiceType>()
public:
generic<typename TServiceType>
TServiceType GetRequiredService()
member GetRequiredService : unit -> 'TServiceType 
JScript では、ジェネリックな型またはメソッドは使用できません。

型パラメーター

  • TServiceType

戻り値

型: TServiceType
要求されたサービスの型のインスタンス。このメソッドが nullnull 参照 (Visual Basic では Nothing) を返すことはありません。

例外

例外 条件
NotSupportedException

要求された型のサービスがありません。

解説

要求された型のサービスが使用できない場合、GetRequiredService<TServiceType> は NotSupportedException をスローします。 nullnull 参照 (Visual Basic では Nothing) が例外の代わりに戻り値として許容される場合は、代わりに GetService を使用してください。 GetRequiredService<TServiceType> を使用すると、コントラクトの信頼性が向上します。

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

ServiceManager クラス

Microsoft.Windows.Design 名前空間

EditingContext

ContextItem

その他の技術情報

WPF デザイナーの機能拡張