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!

Proxying Custom Interfaces

The RCW also acts as a proxy for most the interfaces exposed by the underlying COM object. Some interfaces are consumed by the RCW but not exposed through the RCW (see Consuming Selected interfaces below). The RCW class itself has no members, but it does implement the same interfaces as the COM coclass that it wraps.

Some languages (like Visual Basic) may choose to show the methods of the default interface as methods of the class itself (see the Interop Metadata Spec for details on identifying the default interface). Those languages would then be responsible for directing calls on the class to calls on the default interface of that class. The RCW does nothing to facilitate this.

A user of an RCW can naturally cast from one interface implemented by the RCW to another. The interface definition needs to be available in order for the cast to succeed. For example:

In Managed C++:

#import “AcmeLib.dll”      // provides defintion of Slingshot and IWeapon
Acme.Slingshot ss;         
Acme.IWeapon aw;            
ss = new Acme.Slingshot();   // create the COM object
aw = (IWeapon) ss;         // may throw an InvalidCastException
aw.FireWeapon();      

The caller can check to see if the RCW supports a particular interface before casting with the following code:

In Managed C++:

Acme.Slingshot ss;         
Acme.IWeapon aw;            
ss = new Acme.Slingshot();      
if (aw.GetType().IsInstanceOfType(ss)) 
{
   aw = (IWeapon) ss;         
   aw.FireWeapon();      
}