question

MarkusFreitag-0088 avatar image
0 Votes"
MarkusFreitag-0088 asked JeanineZhang-MSFT commented

C# to C++/MFC duplex mode - Concept

Hello,
I have a static MFC C++ application, I cannot change it. (CLI is not possible)

I now need to pass data from a C# DLL in the C++ application and transfer it from the C++ to the C# DLL. What possibilities do I have to implement this successfully.

110695-concept.png


Can you show an example

 SendDataOrderToCPP(string order, double price, int amount)
    
 ResponseDataOrderToCSharp(string order, double price, int amount)



Is there a possibility that the C# DLL sends an event and I can evaluate the value in the C++ app?


Is it possible that the C++ exe sends an event and I can evaluate the value in the C# DLL?

How would I have to create this?



//----
Background

I need to implement a WinForm in C# in which I can make inputs. I have to analyse these inputs in C++.

After the analysis, I have to send new data from C++ to C# to display the calculated values.

Or I need an additional DLL ?
110675-concept-2.png


dotnet-csharpc++dotnet-cli
concept.png (23.8 KiB)
concept-2.png (26.8 KiB)
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If you can't change the native application, what means does it have that exposes the functionality in it that you want to use?

1 Vote 1 ·

I compile the C++ MFC as a static library and can make few changes in the settings there, hence the idea with the intermediate C++/CLI dll.

0 Votes 0 ·

You say elsewhere that your C++ application is an MFC dialog application, so presumably when you mention static library, you just mean that its built with MFC statically linked to it?

If it's an MFC dialog application, with no existing interface to access the functionality you need, and you can't re-use or alter its source code, its time to give up.

0 Votes 0 ·

There are many things I do not understand. Can you change the MFC program at all? Or is it impossible to make any changes to the MFC program? Or are there some changes but some you cannot make? It is difficult to know what to suggest because we do not know what the requirements are. Does the MFC program call the DLL currently? I do not understand what in the C++ application means. You say from a C# DLL and you say from the C++ so do you mean both directions? Is data going in both directions now or just one direction or none?


1 Vote 1 ·

Can you change the MFC program at all? Or is it impossible to make any changes to the MFC program?

No only if inpossible.

O

r are there some changes but some you cannot make?

Yes

I

t is difficult to know what to suggest because we do not know what the requirements are. Does the MFC program call the DLL currently?

Yes for some function. C# send the inputs of an order.

>I do not understand what in the C++ application means.
MFC dialog C++ App

Y

ou say from a C# DLL and you say from the C++ so do you mean both directions?

Yes both

Is data going in both directions now or just one direction or none?
Yes

Can you make sample, how I can change the data from C# to C++ and back.

Thanks.

0 Votes 0 ·
AgaveJoe avatar image AgaveJoe MarkusFreitag-0088 ·

The community has no idea how your C++ is designed.

Function export is an option.

The official docs cover this subject.

Finally there's Google...



0 Votes 0 ·
Show more comments

@MarkusFreitag-0088

If you could chang the MFC and c# program, as far as I'm concerned you could try to call sendmessage to this aim.


0 Votes 0 ·

0 Answers