CathalMF
CathalMF

Reputation: 10055

Sending information between a unmanaged C++ DLL and a managed C# UI

Ok so the scenario is as followed.

Application1 has the ability to load and make calls to an unmanaged C++ DLL.

I want to write another user interface in C# to make my life easier.

I then want the DLL to be able to send information to the C# executable, and the C# executable to be able to send information to the DLL.

The information being passed back and forth is not complex. It will simply be a string.

Any ideas on how this can be done.

Upvotes: 1

Views: 749

Answers (1)

Yurii
Yurii

Reputation: 4911

This should answer your question. Basically the easiest options are Named Pipes for communication on the same machine, and Sockets for different machines.
Update
After better consideration, the answer depends on 'Who is in control?' in your scenario.
1. If C# executable is responsible for calling your unmanaged DLL and sending/retrieving information, then you should go with Platform Invoke.
2. If you you want your unmanaged DLL to decide when to send data to the application, then first of all you should transform your DLL into full fledged application and after that go with the interprocess communication.

Upvotes: 1

Related Questions