Just for my self and other people like me who forget interestingly fast, and do not wish to get E_NOINTERFACE from C++ QueryInterface method after they add new COM interface version for maintaining backward compatibility for the COM object.

4 places to add the new version info..

1-In the idl file used for the description of the interface, Add the new interface and make sure you put a new UUID for it, make sure it inherits the old interface


[
 object,
 uuid(69BBF687-D8AE-4f7c-8E61-96DD47FA12C8),
 dual,
 helpstring("OldInterface Interface"),
 pointer_default(unique)
 ]
 interface IOldInterface : IDispatch
 {

//Some old functions

};

[
 object,
 uuid(9BFB8CD2-C090-4e37-A9AB-AE001B9EB4DC), //new UUID
 dual,
 helpstring("INewInterface Interface"),
 pointer_default(unique)
 ]
 interface INewInterface : IOldInterface
 {
//Some new functions

};


2-Adding entry in the coclass definition in the same idl file


coclass SomeClass
 {
 [default] interface INewInterface;
 interface IOldInterface;
 };

3-Changing the interface version entry in the .h file you created for the implementation of the COM class


class ATL_NO_VTABLE CSomeClass :
public CComCoClass<CSomeClass, &CLSID_SomeClass>,
 public ISupportErrorInfo,
 public IDispatchImpl<INewInterface, &IID_INewInterface, &LIBID_library_name>
{
//class implementation
}

4-Adding an entry in the COM map in the same .h file

BEGIN_COM_MAP(CSomeClass)
COM_INTERFACE_ENTRY(IOldInterface)
COM_INTERFACE_ENTRY(INewInterface)
COM_INTERFACE_ENTRY2(IDispatch, INewInterface)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

Then I hope we don’t get E_NOINTERFACE error again, that one with the ugly error code -2147467262 (signed long) or 2147500034(unsigned long) or 0x800004002 (hex)
Thanx!