Dual Interfaces
One heavily used but often misunderstood term in COM is dual interface. Put simply, dual interfaces are interfaces that support both early and late binding. Much of the literature on COM implies that Microsoft wants your interfaces to be dual, so you can have the best of both worlds. The problem is, as in life, there are always compromises.
Late binding comes from Visual Basic, so it carries all the type limitations of that language. Basically, if you can't do it in VB, you can't do it in late binding, because you are limited to the Visual Basic types. Thus, late-bound method calls on an interface cannot handle things such as structures, pointers, linked lists, etc., and passing arbitrary length arrays is very clumsy. Fortunately, you can always create an interface that supports early binding only. This will enable the caller to pass almost any standard C structure, data structure, pointer, etc. that RPC supports. However, if you use dual interfaces, your early-binding interface will be constrained to the data types allowed by its less intelligent, late-binding, Siamese twin.
The rules are as follows:
If you are writing a server for use with any language, VB included, and you want to support late and early binding, you should definitely use dual interfaces. All interfaces will derive from IDispatch. You will have to forgo the ability to pass more esoteric, pointer-heavy C data types, but this is often not a sacrifice.
If you writing a COM server designed to be used exclusively by C++ clients, you may use what are called custom interfaces. These interfaces derive from IUnknown, not IDispatch. This means that the COM class will support only early binding. VB may still be able to use this object via early binding, but only if no, structures (except for VARIANTs), linked lists, etc. are used. If they are used, VB will complain that the object uses unsupported data types.
If you have a legacy COM component, or an old automation server, it may support only late binding. If you look at the IDL, you may notice that the interfaces are declared as dispinterfaces. This means late binding exclusively. Early binding is a more recent development.