System.Runtime.InteropServices.ErrorWrapper Class

Wraps objects the marshaler should marshal as a VT_ERROR.

See Also: ErrorWrapper Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ErrorWrapper

Remarks

By default, object type arguments are marshaled as a VARIANT type, where the object type determines the VARTYPE value of the VARIANT.

The System.Runtime.InteropServices.ErrorWrapper type must to be passed as an object type to be marshaled as a VARIANT of type VT_ERROR, otherwise the System.Runtime.InteropServices.ErrorWrapper type is marshaled as an integer.

The following table illustrates marshaling in a managed call to a native function, using platform invoke.

ErrorWrapper[] pArr

ErrorWrapper[10] of ErrorWrapper(77)

Int[10]

Object[] pArr

ErrorWrapper[10] of ErrorWrapper(77)

VARIANT[10] of VT_ERROR

Object[] pArr

Object[10] of ErrorWrapper(77)

VARIANT[10] of VT_ERROR

The following table illustrates marshaling data in a managed call to a native function, using COM runtime callable wrappers (RCW).

ErrorWrapper[] pArr

ErrorWrapper[10] of ErrorWrapper(77)

Int[10]

Object[] pArr

ErrorWrapper[10] of ErrorWrapper(77)

SafeArrayTypeMismatch exception

Object[] pArr

Object[10] of ErrorWrapper(77)

SAFEARRAY(VARIANT)

Note that System.Runtime.InteropServices.ErrorWrapper objects are not marshaled as type VT_ERROR after they are passed back from COM. A single value is marshaled back from COM as type VT_I4, while arrays are marshaled back from COM as type VT_UI4.

For more information on VT_ERROR, please see the existing documentation for VARENUM::VT_ERROR in the MSDN library.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0