Navigation:  Programming Cookbook > Creating COM Components >

Marshalling

Previous pageReturn to chapter overviewNext page

 

Marshalling is the process by which COM orchestrates the transfer of data and correctly synchronised invocation of "remote" methods. This may involve moving data and object references between address spaces, and also performing cross-thread calls safely and correctly.

Dolphin is capable of creating COM server components that run either in-process (.DLL) or out-of-process (.EXE). When running out-of-process the components are running in a separate process, and must therefore be on a separate thread and in a separate address space. Dolphin's in-process components run within the same address space as the client, but are limited to the single-threaded apartment model and will always run on a separate thread. This means that in both cases marshalling support is required for the component's interfaces in order that COM can both synchronize interaction between the client and server threads, and to transfer data between address spaces where needed. So before one can attempt any use (or debugging) of a Dolphin COM component in conjunction with an external client one must first ensure that appropriate marshalling support is registered for the component’s interfaces.

Marshalling can be provided in a number of ways (including a component taking responsibility for its own marshalling by implementing the IMarshal interface, which is referred to as Custom Marshalling), but typically it is built directly or indirectly from the outputs of the MIDL compiler when run against the IDL definition of the component. MIDL output can provide either type-library marshalling, or standard proxy/stub marshalling.