CustomQueryInterface enables users to customize the default implementation of “standard” COM interfaces provided by CLR. We already released a sample
to demo customized IDispatch as well as aggregation between two managed objects.
To further demo the power of CustomQueryInterface and the ability to use the .Net technology (WCF) within COM world, this sample targets the customization of IMarshal interface by using WCF.IMarshal
enables a COM object to define and manage the marshaling of its interface pointers. On the other hand, WCF provides serialization facilities that enable loose coupling, which significantly eases the customization of IMarshal and makes it more flexible.
In this sample, we provide three important things:
- A managed class acts as the COM component which also implements a WCF service.
- A managed class acts as the COM proxy which contains the WCF client.
- A program that demos the usage of the two classes above by passing the IUnknown pointer through the global stream.
Please note that you need to open the solution as the administrator on Vista or Windows 7.