ErrorWrapper ErrorWrapper ErrorWrapper ErrorWrapper Class

定义

警告

此 API 现已过时。

对封送处理程序应该将其作为 VT_ERROR 封送的对象进行包装。Wraps objects the marshaler should marshal as a VT_ERROR.

public ref class ErrorWrapper sealed
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
[System.Obsolete("ErrorWrapper and support for marshalling to the VARIANT type may be unavailable in future releases.")]
public sealed class ErrorWrapper
type ErrorWrapper = class
Public NotInheritable Class ErrorWrapper
继承
ErrorWrapperErrorWrapperErrorWrapperErrorWrapper
属性

示例

首先,下面的代码示例演示一个孤立Int32封送回从作为 COM 对象Int32对象。The following code example first demonstrates a lone Int32 object marshaled back from COM as an Int32 object. 然后演示Int32数组封送处理从 COM 作为UInt32数组。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;  

注解

默认情况下Object作为类型自变量封送VARIANT类型,其中的对象类型决定VARTYPE的值VARIANTBy default, Object type arguments are marshaled as a VARIANT type, where the object type determines the VARTYPE value of the VARIANT.

ErrorWrapper键入必须作为传递Object要作为封送类型VARIANT类型的VT_ERROR; 否则为ErrorWrapper类型被封送为整数。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 值pArr value 作为封送Marshaled as
ErrorWrapper[] pArrErrorWrapper[] pArr ErrorWrapper(77) ErrorWrapper [10]ErrorWrapper[10] of ErrorWrapper(77) Int[10]
Object[] pArrObject[] pArr ErrorWrapper(77) ErrorWrapper [10]ErrorWrapper[10] of ErrorWrapper(77) VARIANT[10]VT_ERRORVARIANT[10] of VT_ERROR
Object[] pArrObject[] pArr 对象 [10] 的 ErrorWrapper(77)Object[10] of ErrorWrapper(77) VARIANT[10]VT_ERRORVARIANT[10] of VT_ERROR

下表说明了对使用 COM 运行时可调用包装 (RCW) 的本机函数的托管调用中封送处理数据。The following table illustrates marshaling data in a managed call to a native function, using COM runtime callable wrappers (RCW).

托管的签名参数Managed signature parameter pArr 值pArr value 作为封送Marshaled as
ErrorWrapper[] pArrErrorWrapper[] pArr ErrorWrapper(77) ErrorWrapper [10]ErrorWrapper[10] of ErrorWrapper(77) Int[10]
Object[] pArrObject[] pArr ErrorWrapper(77) ErrorWrapper [10]ErrorWrapper[10] of ErrorWrapper(77) SafeArrayTypeMismatch 异常SafeArrayTypeMismatch exception
Object[] pArrObject[] pArr 对象 [10] 的 ErrorWrapper(77)Object[10] of ErrorWrapper(77) SAFEARRAY(VARIANT)

请注意,ErrorWrapper作为类型不封送对象VT_ERROR从 COM 传递后Note that ErrorWrapper objects are not marshaled as type VT_ERROR after they are passed back from COM. 单个值从 COM 作为类型进行封送VT_I4,而从 COM 作为类型封送数组VT_UI4A single value is marshaled back from COM as type VT_I4, while arrays are marshaled back from COM as type VT_UI4.

有关详细信息VT_ERROR,现有的文档,请参阅VARENUM::VT_ERRORMSDN 库中。For more information on VT_ERROR, please see the existing documentation for VARENUM::VT_ERROR in the MSDN library.

构造函数

ErrorWrapper(Exception) ErrorWrapper(Exception) ErrorWrapper(Exception) ErrorWrapper(Exception)

使用与所提供的异常相对应的 HRESULT 初始化 ErrorWrapper 类的新实例。Initializes a new instance of the ErrorWrapper class with the HRESULT that corresponds to the exception supplied.

ErrorWrapper(Int32) ErrorWrapper(Int32) ErrorWrapper(Int32) ErrorWrapper(Int32)

使用错误的 HRESULT 初始化 ErrorWrapper 类的新实例。Initializes a new instance of the ErrorWrapper class with the HRESULT of the error.

ErrorWrapper(Object) ErrorWrapper(Object) ErrorWrapper(Object) ErrorWrapper(Object)

使用包含错误 HRESULT 的对象初始化 ErrorWrapper 类的新实例。Initializes a new instance of the ErrorWrapper class with an object containing the HRESULT of the error.

属性

ErrorCode ErrorCode ErrorCode ErrorCode

获取包装的错误代码。Gets the error code of the wrapper.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于