Marshal.GetObjectForNativeVariant Method

Definition

Overloads

GetObjectForNativeVariant(IntPtr)
Obsolete.

Converts a COM VARIANT to an object.

GetObjectForNativeVariant<T>(IntPtr)
Obsolete.

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

GetObjectForNativeVariant(IntPtr)

Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs

Caution

GetObjectForNativeVariant(IntPtr) may be unavailable in future releases.

Converts a COM VARIANT to an object.

C#
[System.Obsolete("GetObjectForNativeVariant(IntPtr) may be unavailable in future releases.")]
[System.Security.SecurityCritical]
public static object GetObjectForNativeVariant(IntPtr pSrcNativeVariant);
C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static object? GetObjectForNativeVariant(IntPtr pSrcNativeVariant);
C#
[System.Obsolete("GetObjectForNativeVariant(IntPtr) may be unavailable in future releases.")]
public static object GetObjectForNativeVariant(IntPtr pSrcNativeVariant);
C#
public static object? GetObjectForNativeVariant(IntPtr pSrcNativeVariant);
C#
public static object GetObjectForNativeVariant(IntPtr pSrcNativeVariant);
C#
[System.Security.SecurityCritical]
public static object GetObjectForNativeVariant(IntPtr pSrcNativeVariant);

Parameters

pSrcNativeVariant
IntPtr

A pointer to a COM VARIANT.

Returns

An object that corresponds to the pSrcNativeVariant parameter.

Attributes

Exceptions

pSrcNativeVariant is not a valid VARIANT type.

pSrcNativeVariant has an unsupported type.

Remarks

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.

See also

Applies to

.NET 10 and other versions
Product Versions (Obsolete)
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 (Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 2.0 (1.2, 1.3, 1.4, 1.5, 1.6, 2.1)
UWP (10.0)

GetObjectForNativeVariant<T>(IntPtr)

Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs

Caution

GetObjectForNativeVariant<T>(IntPtr) may be unavailable in future releases.

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

C#
[System.Obsolete("GetObjectForNativeVariant<T>(IntPtr) may be unavailable in future releases.")]
[System.Security.SecurityCritical]
public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant);
C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static T? GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant);
C#
[System.Obsolete("GetObjectForNativeVariant<T>(IntPtr) may be unavailable in future releases.")]
public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant);
C#
public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant);
C#
[System.Security.SecurityCritical]
public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant);

Type Parameters

T

The type to which to convert the COM VARIANT.

Parameters

pSrcNativeVariant
IntPtr

A pointer to a COM VARIANT.

Returns

T

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

Attributes

Exceptions

pSrcNativeVariant is not a valid VARIANT type.

pSrcNativeVariant has an unsupported type.

Remarks

GetObjectForNativeVariant<T>(IntPtr) returns a managed object of type T 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<T>(IntPtr) provides the opposite functionality of GetNativeVariantForObject<T>(T, IntPtr).

Applies to

.NET 10 and other versions
Product Versions (Obsolete)
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 (Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2)
.NET Framework 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (1.2, 1.3, 1.4, 1.5, 1.6, 2.1)
UWP (10.0)