none
.NET Client and COM Server ---> and back ? RRS feed

  • Question

  •  

    Dear Group,

     

    we have a .NET/C# Winform .EXE that reads and displays medical data. It forwards heavy number-crunching to a COM Server, which can be Matlab or R or Python. Works perfectly. The EXE is rather static, the number-crunching is a flexible plug-in system.

     

    Now, we would like to allow the plug-ins to request additional data from the EXE, or tap some of its hard-wired speedy matrix operations. I know how to program COM->NET request in a DLL, but here I need to make a call to the "mother" EXE instance, not to some out-of-the air data-blind DLL. How would I do:

     

    1) Hello, who is my mother DLL, i.e. the calling client to act as a server for the plugin?

    2) Please, mother EXE, tell me the functions you offer (plugins should be flexible)

     

    Note that a simple callback would not work (or would it?), because it should be possible to query the interface to find the right function to call.

     

    Any example or thoughts would be appreciated.

     

    Dieter

     

     

    Monday, April 21, 2008 2:41 PM

Answers

  • Add an interface to the COM server's IDL, say IHostInterface.  Add all the methods to that interface that the server could use.  Add one method to your server's main interface: HRESULT SetHostInterface([in] IHostInterface* provider).  Build the COM server, then write a managed class that implements IHostInterface: public class HostInterfaceProvider : IHostInterface.  Implement the methods.  In your EXE's startup code, where you connect to the server, call the server's SetHostInterface() method.
    Monday, April 21, 2008 11:52 PM
    Moderator

All replies

  • Add an interface to the COM server's IDL, say IHostInterface.  Add all the methods to that interface that the server could use.  Add one method to your server's main interface: HRESULT SetHostInterface([in] IHostInterface* provider).  Build the COM server, then write a managed class that implements IHostInterface: public class HostInterfaceProvider : IHostInterface.  Implement the methods.  In your EXE's startup code, where you connect to the server, call the server's SetHostInterface() method.
    Monday, April 21, 2008 11:52 PM
    Moderator
  • Terse as Unix docs, but a hit. Thanks a lot, nobugz!

    Dieter

    Tuesday, April 22, 2008 9:02 AM
  • For those who have a similar problem: There is a nice example with C# or VB and R by Balasubramanian Narasimhan
    at

    http://sunsite.univie.ac.at/rcom/download/Tutorial/EmbeddingR_Tutorial.pdf

    Dieter


    Wednesday, April 23, 2008 3:56 PM