Export (0) Print
Expand All

Marshal::GetObjectForNativeVariant<T> Method (IntPtr)

[Supported in the .NET Framework 4.5.1 and later versions]

Converts a COM VARIANT to an object of a specified type.

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

generic<typename T>
static T GetObjectForNativeVariant(
	IntPtr pSrcNativeVariant

Type Parameters


The type to which to convert the COM VARIANT.


Type: System::IntPtr

A pointer to a COM VARIANT.

Return Value

Type: T
An object of the specified type that corresponds to the pSrcNativeVariant parameter.


pSrcNativeVariant is not a valid VARIANT type.


pSrcNativeVariant has an unsupported type.

GetObjectForNativeVariant<T>(IntPtr) returns a managed object of type T that corresponds to a raw pointer to an unmanaged VARIANT type. The interop marshaler performs the identical transformation when exposing a VARIANT type to managed code.

GetObjectForNativeVariant<T>(IntPtr) provides the opposite functionality of GetNativeVariantForObject<T>(T, IntPtr).

.NET Framework

Supported in: 4.6, 4.5.1

Obsolete (compiler warning) in Windows Phone 8.1

  • SecurityCriticalAttribute 

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

© 2015 Microsoft