Re: Calling C# from C++...

Alex Ivanoff <[email protected]> Sat, 15 Dec 2007 00:07:27 -0600
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
You can wrap C# dll in mixed-mode dll using technique similar to this: http://msdn.microsoft.com/msdnmag/issues/05/04/C/.


-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Gyorgy Bozoki
Sent: Friday, December 14, 2007 23:51
To: [email protected]
Subject: [DOTNET-WINFORMS] Calling C# from C++...

Hi all,

I have a problem and I was wondering if someone could give me some advice.

I have a 3rd-party application to which I'm creating a plugin. The plugin
must be a plain Win32 DLL that exports several functions by ordinal. I'll
have to implement the DLL in C/C++, because of memory allocation
requirements - doing this in C# would be very cumbersome.

I also have another DLL written in C# that exposes a few classes and
dialogs, so that users of this DLL can pass some data to these dialogs and
show them on the screen to the user. The DLL is already complete and is used
in several places (all .Net, so far), so I cannot change it in any way.

What I need to do is to use this same C# DLL from my first DLL, which is
written in C++. I know both C++ and C#, but I don't know much about interop
between the two. What would be the best approach to write the C++ DLL so
that it can talk to both the unmanaged 3rd-party app and my managed DLL?

Thanks in advance,
Gyorgy Bozoki