Прочетете на английски Редактиране

Споделяне чрез


DispatchWrapper Class

Definition

Caution

DispatchWrapper and support for marshalling to the VARIANT type may be unavailable in future releases.

Wraps objects the marshaler should marshal as a VT_DISPATCH.

C#
[System.Obsolete("DispatchWrapper and support for marshalling to the VARIANT type may be unavailable in future releases.")]
public sealed class DispatchWrapper
C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public sealed class DispatchWrapper
C#
public sealed class DispatchWrapper
C#
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class DispatchWrapper
Inheritance
DispatchWrapper
Attributes

Remarks

Use to wrap objects the marshaler should marshal as a VT_DISPATCH. This wrapper will force objects to be marshaled out as VT_DISPATCH. If the object does not support IDispatch then an exception will be thrown.

C#
void MyMethod(Object o);

public void DoWrap()
{
    Object o = new MyObject();
    MyMethod(o);                      // passes o as VT_UNKNOWN
    MyMethod(new DispatchWrapper(o)); // passes o as VT_DISPATCH

    //...
}

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

Constructors

DispatchWrapper(Object)

Initializes a new instance of the DispatchWrapper class with the object being wrapped.

Properties

WrappedObject

Gets the object wrapped by the DispatchWrapper.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Продукт Версии (остаряло)
.NET 5, 6, 7, 8, 9, 10 (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
.NET Standard 1.1, 2.0 (1.2, 1.3, 1.4, 1.5, 1.6, 2.1)
UWP (10.0)