English 中文(简体)
C# for UI, c++ for library
原标题:
  • 时间:2009-11-13 18:18:01
  •  标签:
  • c#
  • c++
  • mfc

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

最佳回答

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#.

问题回答

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.

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

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.

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.

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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签