none
How can I get an unmanaged process to talk to a managed process? RRS feed

  • Question

  • Hi everyone

    I need to write a service that has to communicate with a process written in unmanaged code. This service also needs to log to a database. I would love to use LINQ for that but I can't in unmanaged code. So I have some options:

    1.) Write the service in unmanaged code and then find a way to communicate with managed code doing the LINQ work
    2.) Write the service in managed code and then find a way to communicate with the unmanaged process

    How can I get an unmanaged process to talk to a managed process? I don't know anything about managed RPC so this may or may not be my solution.

    Thanks!

    Saturday, April 4, 2009 6:34 PM

Answers

  • There are lots of interprocess communications that are as easily accessible in managed code as they are in unmanaged code.  Well, easier.  Named pipes (.NET 3.5), sockets and out-of-proc COM servers work.  Don't use RPC, COM puts a layer on top that is much easier to get right.  Focus on what you can make work on the unmanaged side.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, April 10, 2009 6:23 AM
    Saturday, April 4, 2009 7:15 PM
    Moderator

All replies

  • There are lots of options that work for communication between native and managed processes.  If they will be on the same machine, I recommend named pipes.  If they will be on other machines, I'd recommend using sockets.

    Saturday, April 4, 2009 7:10 PM
    Moderator
  • There are lots of interprocess communications that are as easily accessible in managed code as they are in unmanaged code.  Well, easier.  Named pipes (.NET 3.5), sockets and out-of-proc COM servers work.  Don't use RPC, COM puts a layer on top that is much easier to get right.  Focus on what you can make work on the unmanaged side.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, April 10, 2009 6:23 AM
    Saturday, April 4, 2009 7:15 PM
    Moderator