Home All Groups Group Topic Archive Search About

Call managed code from unmanaged

Author
3 Oct 2006 1:34 PM
Yoavo
Hi,
I have an C++ MFC application (Unmanaged) and I want to add to this
application a c# DLL which contains dialogs.
The comunication between the C++ application and the c# DLL should be in
both direction.
How can I do it ?
what is the best way ? (I realized that it can be achieved through COM or
MC++).

Yoav.

Author
3 Oct 2006 3:21 PM
William DePalo [MVP VC++]
"Yoavo" <y***@cimatron.co.il> wrote in message
news:OIURvBv5GHA.4616@TK2MSFTNGP05.phx.gbl...
> I have an C++ MFC application (Unmanaged) and I want to add to this
> application a c# DLL which contains dialogs.
> The comunication between the C++ application and the c# DLL should be in
> both direction.
> How can I do it ?
> what is the best way ? (I realized that it can be achieved through COM or
> MC++).

I hate to use adjectives like "best" in the news groups because the "best"
way is sometimes subjective and always dependent on the exact details.

That said, I posted a generic example of native code calling managed code
here:

http://groups.google.com/group/microsoft.public.dotnet.framework.interop/browse_frm/thread/4f4fe6e4347686e3/ad2dcbc2def47d35?tvc=1&q=regasm+group%3Amicrosoft.*+author%3Adepalo&hl=en#ad2dcbc2def47d35

And MSDN has a sample that shows how an MFC application can use WinForms
here:

http://msdn2.microsoft.com/en-us/library/ms239718.aspx

(I think that VS2005 is required)

As for communicating _from_ the managed side, there is always Platform
Invoke.

Regards,
Will

AddThis Social Bookmark Button