This documentation is archived and is not being maintained.

Marshal.GetObjectsForNativeVariants Method

Converts an array of COM VARIANTs to an array of objects.

[Visual Basic]
Public Shared Function GetObjectsForNativeVariants( _
   ByVal aSrcNativeVariant As IntPtr, _
   ByVal cVars As Integer _
) As Object()
public static object[] GetObjectsForNativeVariants(
 IntPtr aSrcNativeVariant,
 int cVars
public: static Object* GetObjectsForNativeVariants(
 IntPtr aSrcNativeVariant,
 int cVars
)  __gc[];
public static function GetObjectsForNativeVariants(
   aSrcNativeVariant : IntPtr,
 cVars : int
) : Object[];


An IntPtr containing the first element of an array of COM VARIANTs.
The count of COM VARIANTs in aSrcNativeVariant.

Return Value

An object array corresponding to aSrcNativeVariant.


Exception Type Condition
ArgumentOutOfRangeException cVars cannot be a negative number.


GetObjectsForNativeVariants returns an array of managed objects corresponding to a raw pointer to a C-style array of unmanaged VARIANT types. The interop marshaler performs the identical transformation when exposing a VARIANT type to managed code. The method returns an empty array when the cVars parameter is 0.

Note   This method uses SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass user input to Marshal class methods without validation. For important limitations on using the LinkDemand member, see Demand vs. LinkDemand.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

Marshal Class | Marshal Members | System.Runtime.InteropServices Namespace