ServiceManager.GetRequiredService<TServiceType> 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取要求的服務。
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 。