2

I'm currently making an application in which I have written the underlying model (logic) in unmanaged C++ (it's just in a Visual Studio C++ Console Application Project at the moment) however I want to create the interface in C# as I understand that it is a lot easier for GUI programming due to WPF.

The model of the code is written in C++ as this is the language I am most familiar with and for reasons of efficiency. Porting this to C# is definitely an option, but I am not very familiar with C# (although I have plenty of experience with Java so I'm sure it's not a big leap) so I'd rather keep my logic in C++.

When looking online I found a previous question related to this here:

Fast C++ program, C# GUI, possible?

However this was from 6 years ago now and I was wondering if there are any newer (and easier) ways to link a C++ project to a C# (GUI) project in Visual Studio 2015? I imagine I would still have to create a managed C++ project via CLR->Class Library in VS, but is there any new stuff out there which can make this whole process easier?

I should also note that the GUI will be required to display real-time graphs if this makes any difference to the method used for making the actual GUI (i.e. is this possible in C# via WPF?)

Community
  • 1
  • 1
sjrowlinson
  • 3,297
  • 1
  • 18
  • 35

1 Answers1

3

Definitely managed C++/CLI is not the most beautiful thing ever, but the whole point of its existence is connecting unmanaged code with .NET world, and it does the job well.

When a solution is available in VS out of box, ready and set, I actually see no reason to search for an alternative.

Ajay
  • 18,086
  • 12
  • 59
  • 105
Diligent Key Presser
  • 4,183
  • 4
  • 26
  • 34
  • 1
    This. I started writing my own answer but realized it's basically the same as this one.. Not extremely beautiful, but as long as you keep your CLI just a tiny layer to expose the C++ meat to .Net you're golden. It just works. Also have a look at https://msdn.microsoft.com/en-us/library/bb384865.aspx for converting strings, shared_ptrs etc – stijn Apr 02 '16 at 17:13