Marshaling Selected Interfaces
The primary goal of the runtime callable wrapper (RCW) is to hide the differences between the managed and unmanaged programming models. To create a seamless transition, the RCW consumes selected COM interfaces without exposing them to the .NET client, as shown in the following illustration.
COM interfaces and the runtime callable wrapper
When created as an early-bound object, the RCW is a specific type. It implements the interfaces that the COM object implements and exposes the methods, properties, and events from the object's interfaces. In the illustration, the RCW exposes the INew interface but consumes the IUnknown and IDispatch interfaces. Further, the RCW exposes all members of the INew interface to the .NET client.
The RCW consumes the interfaces listed in the following table, which are exposed by the object it wraps.
Interface | Description |
---|---|
IDispatch | For late binding to COM objects through reflection. |
IErrorInfo | Provides a textual description of the error, its source, a Help file, Help context, and the GUID of the interface that defined the error (always GUID_NULL for .NET classes). |
IProvideClassInfo | If the COM object being wrapped implements IProvideClassInfo, the RCW extracts the type information from this interface to provide better type identity. |
IUnknown | For object identity, type coercion, and lifetime management:
|
The RCW optionally consumes the interfaces listed in the following table, which are exposed by the object it wraps.
Interface | Description |
---|---|
IConnectionPoint and IConnectionPointContainer | The RCW converts objects that expose the connection-point event style to delegate-based events. |
IDispatchEx | If the class implements IDispatchEx, the RCW implements IExpando. The IDispatchEx interface is an extension of the IDispatch interface that, unlike IDispatch, enables enumeration, addition, deletion, and case-sensitive calling of members. |
IEnumVARIANT | Enables COM types that support enumerations to be treated as collections. |
See Also
Runtime Callable Wrapper | Assembly to Type Library Conversion Summary | Qualifying .NET Types for Interoperation