ServiceProvider.GetService Method (Type)

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

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

See Also

Reference

ServiceProvider Class

ServiceProvider Members

GetService Overload

Microsoft.VisualStudio.Data.Framework Namespace