Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. multiple IDispatches

multiple IDispatches

Scheduled Pinned Locked Moved COM
csharpc++visual-studiocomhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mweiss
    wrote on last edited by
    #1

    I'm writing a com component that has two interfaces that derive from IDispatch. When I compiled the project I got the error: error C2594: 'static_cast' : ambiguous conversions from 'class CExplorerBar *' to 'struct IDispatch *'. So I changed the COM_INTERFACE_ENTRY to COM_INTERFACE_ENTRY2, so I could specify the IDispatch. Now I have 1 error and 3 warning (I'll just post the error): c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void ** )'. Any ideas about what's going on? Thanks. Melinda.

    P 1 Reply Last reply
    0
    • M mweiss

      I'm writing a com component that has two interfaces that derive from IDispatch. When I compiled the project I got the error: error C2594: 'static_cast' : ambiguous conversions from 'class CExplorerBar *' to 'struct IDispatch *'. So I changed the COM_INTERFACE_ENTRY to COM_INTERFACE_ENTRY2, so I could specify the IDispatch. Now I have 1 error and 3 warning (I'll just post the error): c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator >::CreateInstance(void *,const struct _GUID &,void ** )'. Any ideas about what's going on? Thanks. Melinda.

      P Offline
      P Offline
      pba_
      wrote on last edited by
      #2

      You cannot inherit from two interfaces derived from IDispatch, because the IDispatch is not a virtual base class ( as the error message is saying, the compiler cannot decide which base class to consider for casting).You can disambiguate the cast by specifying which base class to consider ( (IDispatch*)(IInterface1*)this). Another issue is that you will have DISPID clashes from the two interfaces ( id 1 assigned to method "test" in iface 1, and for method "clone" for iface2). The solution is dispid encoding ( you can find an article on codeguru about this), manually implementing IDispatch or using tear-off objects.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups