Answer the question
In order to leave comments, you need to log in
How to combine 2 languages C++ and C#?
Hello!
I would like to write the interface in C#, but the calculations of the program in C++.
I read about different methods of how to do this type, but in the end I only got more confused.
As I understand it, there are such ways:
1. Create a separate Win32 DLL project. for C++ and another project for C#, and using the
Dllimport/Dllexport functions to pass values.
2. Write in C++/CLI. Only here I do not understand how to combine them.
Well, I wrote the code in C ++ / CLI, but how can I insert it into a project written in C #?
3. You can also use COM, but I don't understand what this means.
Is it meant to use to create a C++ MFC project and manage without C#?
Here is my confusion.
What do you think is the most convenient and correct way to combine two languages?
And how it is done (please describe it in detail)
Answer the question
In order to leave comments, you need to log in
You yourself have identified the disadvantage.
What can it lead to? Yes, a lot. For example, you have an application that works with finances. You uploaded 15 items out of 70 and failed. Where to dig? what to do?
The solution is to form one request and immediately send it.
Read about transactions, wrap your function in a transaction.
2. Write in C++/CLI. Only here I do not understand how to combine them.
Well, I wrote the code in C ++ / CLI, but how can I insert it into a project written in C #?
If you want to use the library in the future in other projects that are not tied to .NET, then option 1.
MFC is for the GUI, it has little to do with COM.
COM is used until the application is highly modular. To do this, the COM library is registered in the windows registry, do you need it?
Also in .NET there is a problem of working with COM when inheriting interfaces.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question