0

I have a COM class which is accessible only via vtable. It is already distributed to clients. I am planning to allow script access as well, by introducing IDispatch.

In my local tests, it shows client code will not change, but they will require code rebuild, why so?

Logan
  • 184
  • 10
  • It is not a breaking change. Hard to guess, maybe the client-side tooling thinks it is necessary because the type library changed. – Hans Passant May 26 '15 at 16:52
  • 2
    Did you change your main interface to now inherit from IDispatch instead of inheriting from IUnknown? You can't change the inheritance list on a published interface anymore that you can change the list of methods or their arguments. Doing so would cause the vtable slots to shift down to make space for the IDispatch methods. – Euro Micelli May 26 '15 at 16:59
  • yes, exactly. I changed the inheritance to IDispatch from IUnknown. I guess you are right. – Logan May 27 '15 at 07:04
  • You don't have to make the vtable , `IUnknown` interface inherit from `IDispatch`, only the object itself must implement `IDispatch`, which is not a breaking change. – acelent May 27 '15 at 10:36
  • @PauloMadeira yes it is not a breaking change **code wise**, but binary compatibility is broken. As EuroMicelli explains, since older client binaries are not prepared to accept additional `IDispatch` methods' entries in vtable after `IUnknown` and before methods of interest. – Logan May 27 '15 at 17:51
  • @Logan, I'm sorry, I didn't make myself clear. An object may implement many interfaces, and you don't even have to declare them all in a type library's coclass (heck, you may have an object in hands that didn't come from a class factory). You can keep the vtable interface and just add `IDispatch` to the **class** bases. You never touch the vtable interface's definition at all in the process. – acelent May 27 '15 at 18:40
  • @acelent What do you mean "IUnknown interface inherit from IDispatch"? That's absolutely NOT true, they are two distinct interfaces and neither inherits from the other. – Armen Michaeli Nov 29 '19 at 15:48
  • @amn, it seems I mis-edited the comment before I posted it. What I meant was "you don't have to make the vtable of the already published interfaces and classes inherit from `IDispatch`, leave them as inheriting from `IUnknown` to make sure you don't break anything; to add scripting support, you only need to make the actual object implement `IDispatch` somehow in `QueryInterface`." However, `IDispatch` inherits from `IUnknown`; in fact, all COM interfaces do. – acelent Dec 03 '19 at 10:33
  • Yes, you are right about IDispatch inheriting from IUknown -- I made a mistake there. – Armen Michaeli Dec 03 '19 at 10:57

0 Answers0