Retrieves a service of the specified type.
Namespace: Microsoft.VisualStudio.Data.Framework
Assembly: Microsoft.VisualStudio.Data.Framework (in Microsoft.VisualStudio.Data.Framework.dll)
Syntax
'宣言
Public Overridable Function GetService ( _
serviceType As Type _
) As Object
'使用
Dim instance As ServiceProvider
Dim serviceType As Type
Dim returnValue As Object
returnValue = instance.GetService(serviceType)
public virtual Object GetService(
Type serviceType
)
public:
virtual Object^ GetService(
Type^ serviceType
)
public function GetService(
serviceType : Type
) : Object
Parameters
serviceType
Type: System.TypeThe service type.
Return Value
Type: System.Object
Returns the service of the specified type, or returns a null reference (Nothing in Visual Basic) if no service is found.
Implements
IServiceProvider.GetService(Type)
Exceptions
| Exception | Condition |
|---|---|
| ArgumentNullException | The serviceType parameter is a null reference (Nothing in Visual Basic). |
Remarks
This method creates the service through a previously specified callback, returns the existing service, or gets the service through a parent service. If this method is not able to obtain the service, it calls the parent service provider, if one exists.
Permissions
- 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.