简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM