NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Exposing NGWS objects to Classic COM

This section describes the mechanism that makes it possible to use NGWS objects from unmanaged code. This is the mechanism that classic COM clients use to access the services provided by NGWS objects. When a classic COM client creates an instance of an NGWS object, the object is exposed through a COM Callable Wrapper (CCW) that acts as a proxy for the real managed object. These wrappers are not visible within the runtime by other NGWS classes; they are simply there for marshaling calls between managed (NGWS runtime) and unmanaged (classic COM) code. Each NGWS object being referenced outside the runtime will have a single CCW regardless of the number of references that exist on that object. This ensures that a single object identity is shared between the CCW and the COM object.

Figure 1Classic COM client and NGWS runtime client using a NGWS objects IFoo interface

The CCW is really a proxy for the NGWS object being referenced from unmanaged code. It is transparent to the managed object that it is being referenced by a CCW as opposed to a NGWS runtime client. The CCW’s reference on the managed object is traced like any other managed reference. The COM client’s reference on the CCW is reference counted like any other COM reference. If multiple COM clients share a reference to the same managed object, the runtime guarantees that they will share the same CCW. In other words, there will never exist more than one CCW for any instance of a managed class.

The bulk of this section covers the responsibilities of the CCW in detail.