Search code examples
c#deploymentinterfacecom

How to update/change the Interface of already registered COM in C#


I have created a user Control in C# (as a class library). Now I have registered the class (using regasm) and I can use this control on a VBA user-form. All the methods,events and properties works as expected. But When I am trying to add new methods to the Interface, I can't see them in VBA. Is it possible to update an already registered COM's interface?

If yes, can you please provide some guidance.


Solution

  • It depends.

    COM interfaces are generally considered immutable. The "correct" way is to create a new interface IWhatever2 that extends your existing IWhatever that has the new methods.

    However, if you haven't released this yet (i.e. it's still in development and you're the only one using it), you can essentially delete and replace the interface. You'll need to unregister the existing interface (regasm /u) and give your "new" interface a new GUID and register it again.