Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Marshal.GetComInterfaceForObject Method (Object, Type, CustomQueryInterfaceMode)

Note: This API is now obsolete.

Returns a pointer to an IUnknown interface that represents the specified interface on the specified object. Custom query interface access is controlled by the specified customization mode.

Namespace:  System.Runtime.InteropServices
Assemblies:   System.Runtime.InteropServices (in System.Runtime.InteropServices.dll)
  mscorlib (in mscorlib.dll)

[<ObsoleteAttribute("GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) and support for ICustomQueryInterface may be unavailable in future releases.")>]
static member GetComInterfaceForObject : 
        o:Object * 
        T:Type * 
        mode:CustomQueryInterfaceMode -> IntPtr


Type: System.Object

The object that provides the interface.

Type: System.Type

The type of interface that is requested.

Type: System.Runtime.InteropServices.CustomQueryInterfaceMode

One of the enumeration values that indicates whether to apply an IUnknown::QueryInterface customization that is supplied by an ICustomQueryInterface.

Return Value

Type: System.IntPtr
The interface pointer that represents the interface for the object.


The T parameter is not an interface.


The type is not visible to COM.


The T parameter is a generic type.


The object o does not support the requested interface.


The o parameter is a null reference (Nothing in Visual Basic).


The T parameter is a null reference (Nothing in Visual Basic).

GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) lets you specify whether to apply query interface customization. Use the GetComInterfaceForObject(Object, Type) overload to apply query interface customization by default.

.NET Framework

Supported in: 4.6, 4.5, 4
Obsolete (compiler warning) in 4.6

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Obsolete (compiler warning) in Windows Phone 8.1

Portable Class Library

Supported in: Portable Class Library

  • SecurityCriticalAttribute 

    requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

© 2015 Microsoft