Share via


IVsDataHostService.GetService<TService, TInterface> Method

Gets a global Visual Studio service of the specified type that implements the specified interface.

Namespace:  Microsoft.VisualStudio.Data.Core
Assembly:  Microsoft.VisualStudio.Data.Core (in Microsoft.VisualStudio.Data.Core.dll)

Syntax

'Declaration
Function GetService(Of TService, TInterface) As TInterface
'Usage
Dim instance As IVsDataHostService 
Dim returnValue As TInterface

returnValue = instance.GetService()
TInterface GetService<TService, TInterface>()
generic<typename TService, typename TInterface>
TInterface GetService()
JScript does not support generic types or methods.

Type Parameters

  • TService
  • TInterface

Return Value

Type: TInterface
The service instance.

Exceptions

Exception Condition
ServiceNotFoundException

The service was not found.

Remarks

This method should be called for services that are assumed to always be present.

Examples

The following code demonstrates calling this method to retrieve a standard Visual Studio global service using a separate service type and interface type.

using System;
using Microsoft.VisualStudio.Data.Core;
using Microsoft.VisualStudio.Shell.Interop;

public class DdexHostSvcExample6
{
    public static IVsUIShell GetIVsUIShell(IVsDataHostService hostService)
    {
        return hostService.GetService<SVsUIShell, IVsUIShell>();
    }
}

.NET Framework Security

See Also

Reference

IVsDataHostService Interface

IVsDataHostService Members

GetService Overload

Microsoft.VisualStudio.Data.Core Namespace