GetObjectForNativeVariant Method (IntPtr)

Marshal.GetObjectForNativeVariant Method (IntPtr)


Converts a COM VARIANT to an object.

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

public static object GetObjectForNativeVariant(
	IntPtr pSrcNativeVariant


Type: System.IntPtr

A pointer to a COM VARIANT.

Return Value

Type: System.Object

An object that corresponds to the pSrcNativeVariant parameter.

Exception Condition

pSrcNativeVariant is not a valid VARIANT type.


pSrcNativeVariant has an unsupported type.

GetObjectForNativeVariant returns a managed object that corresponds to a raw pointer to an unmanaged VARIANT type. The interopmarshaler performs the identical transformation when exposing a VARIANT type to managed code.

GetObjectForNativeVariant provides the opposite functionality of Marshal.GetNativeVariantForObject.

When the VARIANT type is VT_ERROR, GetObjectForNativeVariant returns an object of type Int32 instead of UInt32.


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

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft