LanguageService::GetSite Method (Guid, IntPtr)

 

Returns an unmarshaled pointer to a requested interface.

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public:
virtual void GetSite(
	Guid% iid,
	[OutAttribute] IntPtr% ptr
) sealed

Parameters

iid
Type: System::Guid

[in] The GUID of the desired interface.

ptr
Type: System::IntPtr

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

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 M:Microsoft.VisualStudio.Shell.ServiceProvider.Microsoft.VisualStudio.OLE.Interop.IObjectWithSite.GetSite(System.Guid@,System.IntPtr@).

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;

}

Return to top
Show: