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#
  4. call c# from managed c++ dll

call c# from managed c++ dll

Scheduled Pinned Locked Moved C#
csharpc++question
5 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.
  • D Offline
    D Offline
    donovan solms
    wrote on last edited by
    #1

    i have a managed c++ dll, now i need to call a c# method(not in dll) from the managed c++ dll. how would i go about it? i cannot find anything on this topic, everywhere people call from unmanaged c++.

    rather have something you don't need, than need something you don't have

    L 1 Reply Last reply
    0
    • D donovan solms

      i have a managed c++ dll, now i need to call a c# method(not in dll) from the managed c++ dll. how would i go about it? i cannot find anything on this topic, everywhere people call from unmanaged c++.

      rather have something you don't need, than need something you don't have

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi again, you can mix all managed languages in one app, provided you use dll's. Each dll/exe can contain only one language. Calling C# from managed C++ is identical to calling managed C++ from C#. :)

      Luc Pattyn [My Articles]

      D 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi again, you can mix all managed languages in one app, provided you use dll's. Each dll/exe can contain only one language. Calling C# from managed C++ is identical to calling managed C++ from C#. :)

        Luc Pattyn [My Articles]

        D Offline
        D Offline
        donovan solms
        wrote on last edited by
        #3

        thanks again for your reply. only problem is that the c# code is not a dll, can i add a reference to a c# exe in a managed c++ dll?

        rather have something you don't need, than need something you don't have

        D L 2 Replies Last reply
        0
        • D donovan solms

          thanks again for your reply. only problem is that the c# code is not a dll, can i add a reference to a c# exe in a managed c++ dll?

          rather have something you don't need, than need something you don't have

          D Offline
          D Offline
          donovan solms
          wrote on last edited by
          #4

          thanks for the help, i added a reference to the c# exe and it works!

          rather have something you don't need, than need something you don't have

          1 Reply Last reply
          0
          • D donovan solms

            thanks again for your reply. only problem is that the c# code is not a dll, can i add a reference to a c# exe in a managed c++ dll?

            rather have something you don't need, than need something you don't have

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi, if your app is basically a C# program that calls a C++ dll, and that dll needs to call back some method in the C# exe, then AFAIK you need to pass a delegate and use it as a function pointer (or whatever it is called nowadays) in the C++ part. Since the delegate type must be known to both the exe and the dll, it seems it must be defined in the dll (again I dont know the details). A more general approach would be to create an additional dll that holds the C# code that is needed by both the C# main part and the C++ dll. Doing so allows the C++ project (and the main C# part) to add a reference to the new C# dll. :)

            Luc Pattyn [My Articles]

            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