ServiceManager.GetRequiredService<TServiceType> 方法

定義

擷取所要求的服務。

public:
generic <typename TServiceType>
 TServiceType GetRequiredService();
public TServiceType GetRequiredService<TServiceType> ();
member this.GetRequiredService : unit -> 'ServiceType
Public Function GetRequiredService(Of TServiceType) () As TServiceType

類型參數

TServiceType

要擷取的服務類型。

傳回

TServiceType

泛型型別,這是服務的執行個體。

例外狀況

沒有指定型別的服務。

備註

不同於 GetService,如果沒有可用的服務,這個方法會擲回 NotSupportedException

適用於