Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
IServiceProvider (Interfaces)
The IServiceProvider interface is a generic access mechanism to locate a globally unique identifier (GUID) identified service

C# Definition:

    interface IServiceProvider {
    void QueryService(ref Guid guidService, ref Guid riid,
        [MarshalAs(UnmanagedType.Interface)] out object ppvObject);

VB Definition:

InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Interface IServiceProvider
    Sub QueryService(ByRef guidService As Guid, ByRef riid As Guid,
    <MarshalAs(UnmanagedType.Interface)> ByRef ppvObject As Object)
End Interface

User-Defined Types:



The IServiceProvider defined here is different with "System.IServiceProvider". To remove name collisition, rename "IServiceProvider" to other name such as "UCOMIServiceProvider". Otherwise, you should use fully qualified namespace to the interface since you will normally use "using System" directive.

The QueryService above does not work for me: ppvObject is always marshalled as IUnknown, as documented in the .Net API docs. I use the following:

    interface IServiceProvider {
    void QueryService(ref Guid guidService, ref Guid riid,
              out IntPtr ppvObject);

I then assign to ppvObject using:

    ppvObject = Marshal.GetComInterfaceForObject(objectWithRequiredInterface,


Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version