Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have request to add new method in already published COM object
interface ItestAutomationServer : IDispatch

add one more out parameter in existing method of following interface
interface ISinkNewAutomationTest : IUnknown 

any one knows how to solve this?

What I have tried:

I have inherited as following and added new method
interface ItestAutomationServer1 : ItestAutomationServer

I have inherited as following and added new method with that extra parameter
interface ISinkNewAutomationTest1 : ISinkNewAutomationTest 
Posted
Updated 12-Feb-19 12:59pm
v2
Comments
F-ES Sitecore 12-Feb-19 10:10am    
Can't help with the specifics on implementation, but this is usually done with interface forwarding. If you add a param to an existing method then it'll break the objects already compiled against it. So instead you create a new method on a new interface that has the relevant params and leave the only interface in place. You change the old interface to call the new interface so old code continues to work, and if the interface is registered correctly any code compiled against the new interface will see the additional parameter.

Normally it is done via a new version of the interface. Than the implemenation is asking for the needed interface and its version. Than use the QueryInterfacemethod to get the supported interface. See the example how to support different intefaces.

Inheritance is a good idea, because it ensures compatibility.
 
Share this answer
 
COM interfaces are immutable you shall not try to change them. You have to create new interfaces. From the documentation[^]:
COM interfaces are immutable. You cannot define a new version of an old interface and give it the same identifier. Adding or removing methods of an interface or changing semantics creates a new interface, not a new version of an old interface.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900