//Support the IServiceProvider interface. public virtual object GetService(Type serviceType) { // Query IUnknown from the service provider IntPtr ppvObject = (IntPtr)0; Guid guidService = serviceType.GUID; Guid guidIntf = VSConstants.IID_IUnknown; int iResult = _sp.QueryService(ref guidService, ref guidIntf, out ppvObject); if (iResult != VSConstants.S_OK) { return(null); } // Return the object to the caller return(System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(ppvObject)); }