Answer the question
In order to leave comments, you need to log in
Is it possible to combine programs written in different languages (C++, C#) in one project in VS2012?
For example, the code for calculating a certain task is written in C ++, it is necessary to illustrate the results of the calculation in a "graphical" form (graphs, pictures, etc.) and I would like to have a graphical interface in general using not MFC, but windows form. Is it possible to create a form, buttons, etc. using C #, and the calculation itself in C ++. Let's say that a calculation written in C ++ is performed by pressing a button. How to combine this in one Visual Studio 2012 project?
Answer the question
In order to leave comments, you need to log in
Create a Solution with two projects, C# Windows Forms and C++ Win32 DLL.
You write your code in C ++, make a dllexport function that accepts, for example, void *, where the data will be added.
In the C# class, use Dllimport, allocate memory through Marshal.AllocHGlobal, pass it to the C ++ function call, it fills something there, then get it through Marshal.Copy and work with it further
https://github.com/FrankStain/tex-conv
This is an example of such a project. Multitasking texture converter.
At the top level is a C# application with a UI on WinForms, all work with the user is done here.
The C++/CLI core, which is a class library, is connected to the top level. This core links the top level to the bottom level, which is represented by a potentially uncountable set of plugins.
The class library in C# is used as if it were an ordinary module.
Specifically for your case, I would recommend doing this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question