Click here to Skip to main content
15,746,534 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two DLLs, one is C++ MFC COM DLL and another is C# WPF User Control DLL.
I want to have the communication between them to happen over COM itself.
Is there any way to achieve this?

PS: I have tried registering the C++ MFC COM DLL as COM server; but unable to find how to call that COM from C# WPF.

What I have tried:

Tried searching over internet but could not find anything particular to my problem statement.
Updated 15-May-23 0:09am

1 solution

The key problem is to register the library and create an instance in your code. Read COM Interop Sample: .NET Client and COM Server from Microsoft and try adapt it for you. Important is the statement

using CLoan;
which imports the library in your project. You need to build it for your code and make it visible for your build process.

Here is another interesting COM article how to build a server.
Share this answer
Saurabh Ashtaputre 16-May-23 2:13am    
Thanks for your inputs KarstenK.
I did try the thing mentioned in the link (COM Interop Sample).
I could call a function of my C++ MFC COM DLL from C# WPF User Control DLL client; I just showed a simple message box.

How can I achieve the communication the other way around i.e. C++ MFC COM DLL (COM server) to call the function present in C# WPF User Control DLL?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900