Compartir a través de


IVsDataHostService.GetService<T> Method

Gets a global Visual Studio service of the specified type.

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

Syntax

'Declaration
Function GetService(Of T) As T
T GetService<T>()
generic<typename T>
T GetService()
abstract GetService : unit -> 'T 
JScript does not support generic types or methods.

Type Parameters

  • T
    The service.

Return Value

Type: T
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 System;
using Microsoft.VisualStudio.Data.Core;
using Microsoft.VisualStudio.Shell.Interop;

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

.NET Framework Security

See Also

Reference

IVsDataHostService Interface

GetService Overload

Microsoft.VisualStudio.Data.Core Namespace