tags:

views:

268

answers:

6

I have a numerical library coded in C++.

I am going to make a UI for the library. I know some MFC. So one solution is to use MFC and make a native application.

The alternative is C#. I know nothing about C#. But I think it should be easy to learn.

Some tutorial for mixed programming of C++ and C# would be very helpful to me.

Thanks!

Yin

+2  A: 

Write your GUI in C# using WinForms or WPF, and call your native code through Platform Invoke.

Instead of P/Invoke, you might want to consider C++/CLI to make a .NET wrapper for your native library.

IMHO using C# is MUCH more easier than MFC, so you are on the right track.

Yacoder
P/Invoke is difficult if it's a true C++ library. You almost have to have a C API for your library to use it. C++/CLI is much more expressive.
Reed Copsey
Depends on the interface of his C++ library, certainly. If it is simple and short, P/Invoke will do.
Yacoder
+8  A: 

I would recommend using Windows Forms or WPF via C# for your GUI.

Take your numerical library, and use C++/CLI to make a .NET wrapper for it. This makes it trivial to use from C# (it looks like any other C# library).

I highly recommend Nishant Sivakumar's C++/CLI articles on CodeProject for learning about C++/CLI and how to wrap C++ libraries. They're fairly well written.

MSDN is a good reference for how to use Windows Forms from C#.

Reed Copsey
+1  A: 

You can use C# very easily to make the UI. You'll need to write a simple wrapper class to call your unmanaged dll, but that is straightforward. check out the msdn page on that subject

TheSean
A: 

Go with C#. MFC is somewhat dated, so if you need to learn something - go for newer technology, do not waste your time with MFC. I'd go for WPF, learning curve is rather steep, but its fun.

BostonLogan
A: 

I'd suggest looking into SWIG. You can write the core part of your code in C++ as a dll, then have a C# UI link against it.

Stephen Newell
A: 

If you have the source to your C++ numerical library, you can modify it to compile as C++/CLI then you can link to it just like any other .NET library. It shouldn't require a large amount of work to modify the source with #defines for C++/CLI conditional compiling.

Mystere Man