locked
Alter Interface of Existing COM DLL RRS feed

  • General discussion

  • I have inherited a COM class library DLL, originally created using ATL in Visual C++ 6. It has since been upgraded to a Visual Studio 2010 project, where it compiles fine and the resulting DLL works fine too (it is used in an Access VBA program).

    I now need to add some functionality which requires changes to one of its interfaces, such as adding an additional method. So I have implemented the new method in the .cpp and .h files corresponding to the interface, declared in exactly the same way as the existing interface methods, and added the new method to the project's .idl file.

    This compiles without errors, and I can register the resulting dll with regsvr32 OK. But my new method does not appear to be there. If I reference thye new DLL in a VBA project, the new method does not appear in the VBA editor or object browser. If I open the DLL in the OLE-COM Object Viewer tool that comes with VS 2010, the new method is not there either. However, if I open the .tlb file that is produced at the sdame time as the dll, the new method is there!

    Is there an extra step to altering an existing COM interface that I have missed?

    Thanks!

    Wednesday, October 24, 2012 3:12 AM

All replies

  • A COM interface is a contract. It should never be changed once published.

    Create a new interface for each version of your DLL. Call QueryInterface for the new interface ID to get the new interface from the old interface.

    Suggested reading: Designing COM Interfaces



    Visual C++ MVP

    Wednesday, October 24, 2012 4:13 AM
  • My recommendation is not to alter the interface, like Sheng said. You should add an new interface with the enhanced functionality that inherits the functionality of your "old" interface and adds the new functionality.

    Old applications are able to use the "old" interface like it is, new application may use the new interface. You will find enhanced interfaces often, i.e. IContextMenu, IContextMenu2, IContextMenu3.

    Regarding your problem you should really check if your COM DLL is correctly registered and on the space that is stated in the registry. Maybe your old DLL is there somewhere?

    Wednesday, October 24, 2012 5:05 AM