how to communicate between MC++ and C#

  • Thread starter Thread starter Nuno
  • Start date Start date
N

Nuno

Hi

I have some legacy code written in C++ and I am trying to add a GUI (plus
some other functionalities) using C#.
Thus the problem that I am facing is to have C# and C++ live together. I am
thinking that the 2 worlds would communicate using a managedC++ layer.

So in C# I have some utilities functions that I would like to be able to use
from my managed C++ .
How can I call a C# function ( say void DisplayLogMessage(string message) )
from the managed C++ side?
What I need is the most efficient (performance and memory wise) approach.

Thanks.
Nuno.
 
Hi,


Nuno said:
Hi

I have some legacy code written in C++ and I am trying to add a GUI (plus
some other functionalities) using C#.
Thus the problem that I am facing is to have C# and C++ live together. I
am thinking that the 2 worlds would communicate using a managedC++ layer.

You can call unmanaged code from C# , if the C++ code is in a COM component
all you have to do is add a reference form the IDE and it will create all
the needed glue.
If the C++ is a win32 dll , then you will have to use P/Invoke it's easy
unless you have complex structures you need to pass back and forth.
 
Back
Top