1

I am attempting to add some functionality to a COM object by including another Interface called INvRtrProtocolEx3Itf. However I am running into errors when compiling. I have researched the error code and the page gave some examples of the error and how to fix it but none showed an example using the COM_INTERFACE_ENTRY method.

I found similar questions on here, QUESTION 1 and QUESTION 2 but they both refer to BEGIN_MESSAGE_MAP errors and not the BEGIN_COM_MAP errors...

I am new to COM but I am working on a Project that uses it extensively. I am using another COM object for reference that uses the interface I am trying to add but now I am stuck on where to go about fixing this error. How do I go about getting the COM object to compile or where could I look to fix the issue?

Here is the Code

BEGIN_COM_MAP(CNvRtrProtocolXxxImpl)
    COM_INTERFACE_ENTRY(INvRtrProtocolXxxItf)
    COM_INTERFACE_ENTRY(INvRtrProtocol4Itf)
    COM_INTERFACE_ENTRY(INvComponent3Itf)
    //added the following line to add another interface
    COM_INTERFACE_ENTRY(INvRtrProtocolEx3Itf) //throws error 1 (C2440)
    COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP() //throws error 2 (C2440)

Error 1

error C2440: 'static_cast': cannot convert from 'CNvRtrProtocolXxxImpl::_ComMapClass *' to 'INvRtrProtocolEx3Itf *'

Error 2

error C2440: 'initializing': cannot convert from 'ATL::_ATL_CREATORARGFUNC (__cdecl *)' to 'DWORD_PTR'
RAZ_Muh_Taz
  • 4,059
  • 1
  • 13
  • 26
  • Have you declared the new interface in the IDL file? – Richard Critten Aug 03 '17 at 18:26
  • Are you sure `CNvRtrProtocolXxxImpl` actually implements this new interface? You need to extend `CNvRtrProtocolXxxImpl` from it publicly, as well as add it to the Com Map. – lcs Aug 03 '17 at 18:29
  • @RichardCritten I looked at the IDL file in the other COM object that uses the interface and it doesn't add it to its coclass... it's commented out and still compiles. – RAZ_Muh_Taz Aug 03 '17 at 18:33
  • @lcs Let me double check all the signatures and so on to make sure they are implemented exactly as specified by the interface... – RAZ_Muh_Taz Aug 03 '17 at 18:36
  • @lcs So there is a class I extend called CRtrProtocolExBase which uses all the methods for the INvRtrProtocolEx3Itf interface. I have implemented all the those functions. This is the same class that is extended by the other COM object that implements the INvRtrProtocolEx3Itf interface... – RAZ_Muh_Taz Aug 03 '17 at 18:46
  • @lcs I think you are right, some of the signatures are slightly different. I will go through them 1 by 1 – RAZ_Muh_Taz Aug 03 '17 at 18:50
  • You need to make sure `static_cast != nullptr` is valid for whichever class you list `INvRtrProtocolEx3Itf` in the com map. – lcs Aug 03 '17 at 19:19
  • @RichardCritten I declared the interface in the IDL file and still no luck, same errors as before – RAZ_Muh_Taz Aug 03 '17 at 21:38
  • `CNvRtrProtocolXxxImpl` must derive from `INvRtrProtocolEx3Itf` in your C++ code. The interface doesn't have to be mentioned in the IDL, but it does need to appear in the C++ class definition. – Igor Tandetnik Aug 05 '17 at 05:02

1 Answers1

2

I have the same issue with _IDTExtensibility2. In my case the solution proposed on this page fixed the issue.

cd C:\Program Files (x86)\Common Files\Designer
regsvr32 MSADDNDR.dll

And then the compilation magically works.

dozy5341
  • 21
  • 2