0
votes

I am using out-of-process COM object that is hosted by myexe.exe. There are multiple versions of those exes which host the COM object. Each version can have slightly changed interfaces and methods. Each of myexe.exe files are located in versioned folders(e.g. C:\v2\myexe.exe, c:\v3\myexe.exe)

There is no way to know ahead of time which of the versions will be running. My client application attaches to the running exes using ROT. I need to be able to use that COM object version dynamically, discovering interfaces through IUnknown.QueryInterface.

Unfortunately I am getting crash when using newer methods if older version of COM is registered in Windows Registry. Once I register newer version of out-of-proces COM in windows registry using "myexe.exe -regserver" the crash goes away. So i cannot dynamically use older or newer version of meexe.exe at runtime as each time i need to re-register my com version.

Any ideas on why i get the crash or how to solve the problem?

2
Do you mean you're using the same interface id (IID) with different interface definitions / layout? - Simon Mourier
yes. I dont want to rely on windows registry definition of the interface. I want to call it dynamically like in this article: forums.codeguru.com/… - SanityMaker
Not sure what you're doing/looking for exactly. You talk about IDispatch in others' comments. You should explain better. One thing for sure, you cannot change an IUnknown-derived interface ("early binding") without changing its IID. It's a binary contract carved in stone. - Simon Mourier

2 Answers

0
votes

COM interfaces are never versioned. Each COM interface is as different as any other. You use IIDs to differentiate and go from one to another using QueryInterface().

See QueryInterface guidelines and the Guide.

0
votes

COM interfaces are immutable. Once you have defined an interface and start using it in your apps, you CAN'T change it anymore. Its IID and VTABLE are locked in. If you need to make changes to existing methods, or add new methods, you MUST create a new interface with a new IID for that purpose (the new interface can derive from the previous interface, though that is not required). The server must then implement the new interface, and clients can QueryInterface() the server for the new interface when needed. There is no getting around this, it is a fundamental rule of COM, so as not to break existing clients when creating new server versions.