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. Managed C++/CLI
  4. I nead to pass an Interface from the C++ wrapper into a C# class

I nead to pass an Interface from the C++ wrapper into a C# class

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++algorithmssaleshelp
8 Posts 3 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.
  • O Offline
    O Offline
    Ole Morten Heien
    wrote on last edited by
    #1

    Folks.. I have created a wrapper project that exports two procedures that I pick up in my Win32 program created in something called Clarion for Windows. The wrapper class calls my C# objects and this works just fine. Problem is that my C# program neads different calls back to my Clarion Win32 program. For instance, my Win32 program has a function to generate new Customer ID's and the complexity of this routine is to much. Becides, I would really like to know if there is a way to do this. The connection between Clarion Win32 and C++ is by using a standard interface decleared in Clarion and passed into the exported function in C++. Problem is that I dont know how to call back to C++ Hers what I have: Clarion(Win32) <=> C++ => C# So Clarion can call C++ methods directly through the Interface, and therfor implicit Clarion can call .NET methods through this wrapper. But I nead the other way too. I was hoping I could pass an Interface from C++ into my C# objects, maybe something like this: MyNetClass::TakeCppInterface(ThisCppInterface); I have posted on the MSDN, but only answer I got there was using MSIL or reflection, which i think is way over my head at the moment.

    ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

    R 1 Reply Last reply
    0
    • O Ole Morten Heien

      Folks.. I have created a wrapper project that exports two procedures that I pick up in my Win32 program created in something called Clarion for Windows. The wrapper class calls my C# objects and this works just fine. Problem is that my C# program neads different calls back to my Clarion Win32 program. For instance, my Win32 program has a function to generate new Customer ID's and the complexity of this routine is to much. Becides, I would really like to know if there is a way to do this. The connection between Clarion Win32 and C++ is by using a standard interface decleared in Clarion and passed into the exported function in C++. Problem is that I dont know how to call back to C++ Hers what I have: Clarion(Win32) <=> C++ => C# So Clarion can call C++ methods directly through the Interface, and therfor implicit Clarion can call .NET methods through this wrapper. But I nead the other way too. I was hoping I could pass an Interface from C++ into my C# objects, maybe something like this: MyNetClass::TakeCppInterface(ThisCppInterface); I have posted on the MSDN, but only answer I got there was using MSIL or reflection, which i think is way over my head at the moment.

      ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

      R Offline
      R Offline
      Radhakrishnan G
      wrote on last edited by
      #2

      You can use a C++/CLI wrapper instead of C++ wrapper so that C++/CLI wrapper can use directly in C#

      O 1 Reply Last reply
      0
      • R Radhakrishnan G

        You can use a C++/CLI wrapper instead of C++ wrapper so that C++/CLI wrapper can use directly in C#

        O Offline
        O Offline
        Ole Morten Heien
        wrote on last edited by
        #3

        Well, isnt that what I allready do ;-) I nead to call back to C++ from the C# Her's the flow: Clarion(Win32) Calls C++ method. C++ then calls C# method. C# Method calls C++ Method. C++ Method Calls Clarion(Win32) Method now, Clarion and C++ can comunisafe over an Interface C++ and C# communicates through a class But what can I use to communicate C# to C++ ?

        ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

        R P 2 Replies Last reply
        0
        • O Ole Morten Heien

          Well, isnt that what I allready do ;-) I nead to call back to C++ from the C# Her's the flow: Clarion(Win32) Calls C++ method. C++ then calls C# method. C# Method calls C++ Method. C++ Method Calls Clarion(Win32) Method now, Clarion and C++ can comunisafe over an Interface C++ and C# communicates through a class But what can I use to communicate C# to C++ ?

          ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

          R Offline
          R Offline
          Radhakrishnan G
          wrote on last edited by
          #4

          can you provide a code snippet

          1 Reply Last reply
          0
          • O Ole Morten Heien

            Well, isnt that what I allready do ;-) I nead to call back to C++ from the C# Her's the flow: Clarion(Win32) Calls C++ method. C++ then calls C# method. C# Method calls C++ Method. C++ Method Calls Clarion(Win32) Method now, Clarion and C++ can comunisafe over an Interface C++ and C# communicates through a class But what can I use to communicate C# to C++ ?

            ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

            P Offline
            P Offline
            Philippe Mori
            wrote on last edited by
            #5

            Well the solution depends on the dependencies between DLL. Assuming that Clarion is using a DLL with C++/CLI code and that DLL is using a C# DLL, then you would also define an interface in C# DLL that will be implementend by C++ code when calling back into C++. Delegates or events could also be used in some cases. This is particulary interesting if for each C# method, you already know which (single) method would be called during processing.

            Philippe Mori

            O 1 Reply Last reply
            0
            • P Philippe Mori

              Well the solution depends on the dependencies between DLL. Assuming that Clarion is using a DLL with C++/CLI code and that DLL is using a C# DLL, then you would also define an interface in C# DLL that will be implementend by C++ code when calling back into C++. Delegates or events could also be used in some cases. This is particulary interesting if for each C# method, you already know which (single) method would be called during processing.

              Philippe Mori

              O Offline
              O Offline
              Ole Morten Heien
              wrote on last edited by
              #6

              Yes. This is what I had in mind.. But I'm not sure how to implement a C# interface in C++. As far as I know, the C# Interface is not C++ compatible becasue C++ actually dont have interfaces (i'm a noob in C++ so this statement is based on things I have read etc.)

              ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

              P 1 Reply Last reply
              0
              • O Ole Morten Heien

                Yes. This is what I had in mind.. But I'm not sure how to implement a C# interface in C++. As far as I know, the C# Interface is not C++ compatible becasue C++ actually dont have interfaces (i'm a noob in C++ so this statement is based on things I have read etc.)

                ----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------

                P Offline
                P Offline
                Philippe Mori
                wrote on last edited by
                #7

                To implement the interface just derive from it as you would do in C#.

                Philippe Mori

                O 1 Reply Last reply
                0
                • P Philippe Mori

                  To implement the interface just derive from it as you would do in C#.

                  Philippe Mori

                  O Offline
                  O Offline
                  Ole Morten Heien
                  wrote on last edited by
                  #8

                  I wil take this under consideration If I reopen the project. As by now, the whole thing is done using a .NET EXE and parameters

                  ----------------------------- Ole Morten Heien HD Software / Advisor AS -----------------------------

                  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