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. Call a running C# application from a C++ application

Call a running C# application from a C++ application

Scheduled Pinned Locked Moved COM
questioncsharpc++com
3 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.
  • S Offline
    S Offline
    scchan1984
    wrote on last edited by
    #1

    Hi, I have a C# windows application which is already running. I have another C++ application. I want to use the C++ application to send parameters or call functions in that running C# windows application. What should I do? I am new in COM. I guess the C++ application uses something like getObject to get the running C# windows application object. Am I correct? But how can I expose the COM interface in that running C# windows application, as it is not a componenet. Thanks

    L 2 Replies Last reply
    0
    • S scchan1984

      Hi, I have a C# windows application which is already running. I have another C++ application. I want to use the C++ application to send parameters or call functions in that running C# windows application. What should I do? I am new in COM. I guess the C++ application uses something like getObject to get the running C# windows application object. Am I correct? But how can I expose the COM interface in that running C# windows application, as it is not a componenet. Thanks

      L Offline
      L Offline
      Lim Bio Liong
      wrote on last edited by
      #2

      Hello scchan1984, You would definitely need COM interop for a C++ COM application to connect with a C# object. The normal scenario in which this is achieved involves C# components housed in libraries. However, the catch is that your C# object is contained inside a C# application (.exe). One way you can possibly achieve interop in this case would be through .NET Remoting. To do this, you would need to make your C# class derive from MarshalByRefObject. It would also help if you could define an interface for the methods and properties that are to be exposed from your C# class to the C++ COM client. Your COM client would then need to connect with your C# class (via Remoting) by using CLR hosting. I'll see if I can come up with some example code that can achieve all this. Regards, Bio.

      1 Reply Last reply
      0
      • S scchan1984

        Hi, I have a C# windows application which is already running. I have another C++ application. I want to use the C++ application to send parameters or call functions in that running C# windows application. What should I do? I am new in COM. I guess the C++ application uses something like getObject to get the running C# windows application object. Am I correct? But how can I expose the COM interface in that running C# windows application, as it is not a componenet. Thanks

        L Offline
        L Offline
        Lim Bio Liong
        wrote on last edited by
        #3

        Hello scchan1984, I managed to develope and run a sample C++ app that creates a C# object (in a C# exe app) as a COM object. .NET Remoting can definitely do the job. However, I must indicate that the development process is quite involved. If you are interested in my sample app, pls email me : bio_lim_2004@yahoo.com Best Regards, Bio.

        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