ErrorWrapper Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
ErrorWrapper and support for marshalling to the VARIANT type may be unavailable in future releases.
Wraps objects the marshaler should marshal as a VT_ERROR
.
public ref class ErrorWrapper sealed
[System.Obsolete("ErrorWrapper and support for marshalling to the VARIANT type may be unavailable in future releases.")]
public sealed class ErrorWrapper
public sealed class ErrorWrapper
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class ErrorWrapper
[<System.Obsolete("ErrorWrapper and support for marshalling to the VARIANT type may be unavailable in future releases.")>]
type ErrorWrapper = class
type ErrorWrapper = class
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type ErrorWrapper = class
Public NotInheritable Class ErrorWrapper
- Inheritance
-
ErrorWrapper
- Attributes
The following code example first demonstrates a lone Int32 object marshaled back from COM as an Int32 object. It then demonstrates an Int32 array marshaled back from COM as a UInt32 array.
// Scenario 1:
// Pass a single value.
Int32 x = 3;
Object o = new ErrorWrapper(x);
// Pass 'o' to COM.
// On the return trip, 'o' has been unwrapped and is still an Int32 object.
Int32 y = (Int32)o;
Scenario 2:
// Pass an array of values.
Int32[] arr = new Int32[3];
Object o = new ErrorWrapper(arr);
// Pass 'o' to COM.
// On the return trip, 'o' has been unwrapped and is now a UInt32[] array.
UInt32[ ] arr2 = (UInt32[])o;
By default, Object type arguments are marshaled as a VARIANT
type, where the object type determines the VARTYPE
value of the VARIANT
.
The ErrorWrapper type must to be passed as an Object type to be marshaled as a VARIANT
of type VT_ERROR
, otherwise the ErrorWrapper type is marshaled as an integer.
The following table illustrates marshaling in a managed call to a native function, using platform invoke.
Managed signature parameter | pArr value | Marshaled as |
---|---|---|
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).
Managed signature parameter | pArr value | Marshaled as |
---|---|---|
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 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.
Error |
Initializes a new instance of the ErrorWrapper class with the HRESULT that corresponds to the exception supplied. |
Error |
Initializes a new instance of the ErrorWrapper class with the HRESULT of the error. |
Error |
Initializes a new instance of the ErrorWrapper class with an object containing the HRESULT of the error. |
Error |
Gets the error code of the wrapper. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string that represents the current object. (Inherited from Object) |
Product | Versions (Obsolete) |
---|---|
.NET | 5, 6, 7, 8, 9 (Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1) |
.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 (4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)) |
.NET Standard | 1.1, 2.0 (1.2, 1.3, 1.4, 1.5, 1.6, 2.1) |
UWP | (10.0) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: