Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

Marshal.GetTypedObjectForIUnknown Method

Returns a managed object of a specified type that represents a COM object.

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

public static Object GetTypedObjectForIUnknown(
	IntPtr pUnk,
	Type t


Type: System.IntPtr

A pointer to the IUnknown interface of the unmanaged object.

Type: System.Type

The type of the requested managed class.

Return Value

Type: System.Object
An instance of the class corresponding to the Type object that represents the requested unmanaged COM object.


t is not attributed with System.Runtime.InteropServices.ComImportAttribute.


t is a Windows Runtime type.

The t parameter must be either a COM-imported type or a subtype of a COM-imported type. In addition, t must be a type whose metadata was imported by the Tlbimp.exe (Type Library Importer) tool. This type must be a class and not an associated coclass interface, which carries the name of the COM class. For example, if Tlbimp.exe imports Myclass as a class called MyclassClass and as a coclass interface called Myclass, you must use MyclassClass (not Myclass) with this method. For additional information about imported classes and coclass interfaces, see Imported Type Conversion.

If an object has already been obtained for the pUnk parameter, t is ignored and the existing object is returned. pUnk represents an IUnknown interface pointer; however, because all COM interfaces derive directly or indirectly from IUnknown, you can pass any COM interface to this method. The object returned by GetTypedObjectForIUnknown is a Runtime Callable Wrapper (RCW), which the common language runtime manages as it does any other managed object.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

  • SecurityCriticalAttribute 

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

© 2015 Microsoft