Compartilhar via


LanguageService.GetSite Method

Returns an unmarshaled pointer to a requested interface.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)

Syntax

'Declaration
Public Sub GetSite ( _
    ByRef iid As Guid, _
    <OutAttribute> ByRef ptr As IntPtr _
)
public void GetSite(
    ref Guid iid,
    out IntPtr ptr
)
public:
virtual void GetSite(
    Guid% iid, 
    [OutAttribute] IntPtr% ptr
) sealed
abstract GetSite : 
        iid:Guid byref * 
        ptr:IntPtr byref -> unit  
override GetSite : 
        iid:Guid byref * 
        ptr:IntPtr byref -> unit
public final function GetSite(
    iid : Guid, 
    ptr : IntPtr
)

Parameters

  • iid
    Type: Guid%

    [in] The GUID of the desired interface.

  • ptr
    Type: IntPtr%

    [out] Returns an unmarshaled interface pointer or a null value if the interface is not available.

Implements

IObjectWithSite.GetSite(Guid%, IntPtr%)

Remarks

This method queries the site (also known as a service provider) for the specified interface and returns a pointer to that interface. This method is an implementation of IObjectWithSite.GetSite.

Examples

This example shows how to get a pointer to an interface and marshal the pointer into an actual interface object.

IVsLanguageService GetLanguageService()
{
    IVsLanguageService pLanguageService = null;
    IntPtr ptr = IntPtr.Zero;
    GetSite(typeof(IVsLanguageService),ptr);
    if (ptr != IntPtr.Zero)
    {
        pLanguageService = (IVsLanguageService)Marshal.GetObjectForIUnknown(ptr);
    }
    return pLanguageService;

}

.NET Framework Security

See Also

Reference

LanguageService Class

Microsoft.VisualStudio.Package Namespace