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. C / C++ / MFC
  4. Hello

Hello

Scheduled Pinned Locked Moved C / C++ / MFC
comcsharpc++jsonhelp
11 Posts 3 Posters 2 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 MrKBA

    Hello, I have a C# dll (COM) which contains API which have a parameter like below :

    [type: ComVisible(true)]
    [Guid("66F046BC-D97C-4CF2-96B5-01E66329FC65")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface ICDBrowserServiceMgr
    {
    [DispId(15)]
    void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);

    ...}

    Now I need to integrate this dll in MFC application So I put the import directive

    #import "SeeSPMPLMClient.dll" // for the use of ISeeSPMPLMClientPtr
    #import "My_dll.tlb" // to use the API

    after i do

    My_Dll_Namespace::ICDBrowserServiceMgrPtr m_pICDBrowser;
    SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;

    m_pICDBrowser->Initialize(m_pPLMClientMgr);

    I ahve the error : error C2664: 'My_Dll::ICDBrowserServiceMgr::Initialize' : cannot convert parameter 1 from 'SeeSPMPLMClientLib::ISeeSPMPLMClientPtr' to 'My_Dll_Namespace::ISeeSPMPLMClient *' Any idea please ?

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    khaliloenit wrote:

    Any idea please ?

    As the message says, you cannot pass a SeeSPMPLMClientLib::ISeeSPMPLMClientPtr to a method that expects a My_Dll_Namespace::ISeeSPMPLMClient *. Check the documentation and the header files to see exactly what you should be passing across.

    Veni, vidi, abiit domum

    M 1 Reply Last reply
    0
    • L Lost User

      khaliloenit wrote:

      Any idea please ?

      As the message says, you cannot pass a SeeSPMPLMClientLib::ISeeSPMPLMClientPtr to a method that expects a My_Dll_Namespace::ISeeSPMPLMClient *. Check the documentation and the header files to see exactly what you should be passing across.

      Veni, vidi, abiit domum

      M Offline
      M Offline
      MrKBA
      wrote on last edited by
      #3

      as you see above the API take as parameter the same type which I pass from C++ !!!

      L 1 Reply Last reply
      0
      • M MrKBA

        as you see above the API take as parameter the same type which I pass from C++ !!!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        Er, No; otherwise the compiler would not be producing that error message.

        Veni, vidi, abiit domum

        M 1 Reply Last reply
        0
        • L Lost User

          Er, No; otherwise the compiler would not be producing that error message.

          Veni, vidi, abiit domum

          M Offline
          M Offline
          MrKBA
          wrote on last edited by
          #5

          this is cant be caused by ambiguity of namespaces ? i.e : if this type is used in C# dll and after passed from other project which use same type we have ambiguity of Type ?

          L 1 Reply Last reply
          0
          • M MrKBA

            this is cant be caused by ambiguity of namespaces ? i.e : if this type is used in C# dll and after passed from other project which use same type we have ambiguity of Type ?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            As I said before, you need to look at the .tlb and .h files to check exactly what object you should be passing.

            Veni, vidi, abiit domum

            1 Reply Last reply
            0
            • M MrKBA

              Hello, I have a C# dll (COM) which contains API which have a parameter like below :

              [type: ComVisible(true)]
              [Guid("66F046BC-D97C-4CF2-96B5-01E66329FC65")]
              [InterfaceType(ComInterfaceType.InterfaceIsDual)]
              public interface ICDBrowserServiceMgr
              {
              [DispId(15)]
              void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);

              ...}

              Now I need to integrate this dll in MFC application So I put the import directive

              #import "SeeSPMPLMClient.dll" // for the use of ISeeSPMPLMClientPtr
              #import "My_dll.tlb" // to use the API

              after i do

              My_Dll_Namespace::ICDBrowserServiceMgrPtr m_pICDBrowser;
              SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;

              m_pICDBrowser->Initialize(m_pPLMClientMgr);

              I ahve the error : error C2664: 'My_Dll::ICDBrowserServiceMgr::Initialize' : cannot convert parameter 1 from 'SeeSPMPLMClientLib::ISeeSPMPLMClientPtr' to 'My_Dll_Namespace::ISeeSPMPLMClient *' Any idea please ?

              S Offline
              S Offline
              Stefan_Lang
              wrote on last edited by
              #7

              m_pICDBrowser is a variable of a type defined in the namespace My_Dll_Namespace, therefore the method Initialize is also defined in that namespace, and, according to the compiler error message, expects an argument of pointer to a type that's also defined in that namespace. You however pass an argument that's defined in an entirely different namespace, SeeSPMPLMClientLib - it's a different type.

              GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

              M 1 Reply Last reply
              0
              • S Stefan_Lang

                m_pICDBrowser is a variable of a type defined in the namespace My_Dll_Namespace, therefore the method Initialize is also defined in that namespace, and, according to the compiler error message, expects an argument of pointer to a type that's also defined in that namespace. You however pass an argument that's defined in an entirely different namespace, SeeSPMPLMClientLib - it's a different type.

                GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                M Offline
                M Offline
                MrKBA
                wrote on last edited by
                #8

                As you see above I pass the same type :

                public interface ICDBrowserServiceMgr
                {
                [DispId(15)]
                void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);

                ...}

                and in call

                SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;

                m_pICDBrowser->Initialize(m_pPLMClientMgr);

                S 1 Reply Last reply
                0
                • M MrKBA

                  As you see above I pass the same type :

                  public interface ICDBrowserServiceMgr
                  {
                  [DispId(15)]
                  void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);

                  ...}

                  and in call

                  SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;

                  m_pICDBrowser->Initialize(m_pPLMClientMgr);

                  S Offline
                  S Offline
                  Stefan_Lang
                  wrote on last edited by
                  #9

                  You're missing my point. Check the type of

                  m_pICDBrowser

                  ! the function

                  Initialize()

                  you are calling here is not the one you think you are calling!

                  GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                  M 1 Reply Last reply
                  0
                  • S Stefan_Lang

                    You're missing my point. Check the type of

                    m_pICDBrowser

                    ! the function

                    Initialize()

                    you are calling here is not the one you think you are calling!

                    GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                    M Offline
                    M Offline
                    MrKBA
                    wrote on last edited by
                    #10

                    Not understand , please can you explain more ?!!

                    S 1 Reply Last reply
                    0
                    • M MrKBA

                      Not understand , please can you explain more ?!!

                      S Offline
                      S Offline
                      Stefan_Lang
                      wrote on last edited by
                      #11

                      Maybe it's best you take another look at the error message you got. In the line

                      m_pICDBrowser->Initialize(m_pPLMClientMgr);

                      the error message states that it cannot convert the first parameter in the call (m_pPLMClientMgr to the type that the function expects. According to the error message, the type of m_pPLMClientMgr is SeeSPMPLMClientLib::ISeeSPMPLMClientPtr, but the type it expects is My_Dll_Namespace::ISeeSPMPLMClient *. This implies, that you have a type ISeeSPMPLMClientPtr defined somewhere in namespace SeeSPMPLMClientLib, but it is not defined as the required type My_Dll_Namespace::ISeeSPMPLMClient *. I suspect that you mixed up the two namespaces. Maybe you inserted a using namespace somewhere (always a bad idea), and then you no longer saw what namespace the definitions and types refer to, or maybe you just have a wrong type definition.

                      GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                      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