語言

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不同,此方法若服務不可用,則拋出 a NotSupportedException 。

適用於