1

I am having a C++ project. i would like to port it to a C#.NET project. I have done some research and I think the most popular way is to use pinvoke.

I dont know whether there are also other methods existed?

Thanks in advance.

olidev
  • 18,940
  • 49
  • 129
  • 194

4 Answers4

6

You can:

1) Rewrite the entire project in C#

2) Reuse several components using either:

  • P/Invoke to reuse unmanaged compiled code

    or

  • C++/CLI to create wrapper classes

Krizz
  • 11,104
  • 1
  • 29
  • 43
2

Well, plain P/Invoke is good to interface with C, but if you want to interop with some real C++ code, you would have to use something more sophisticated. With .NET, you can use C++/CLI. On Mono on and .NET you can use:

First option is less mature but seems to be more elegant.

konrad.kruczynski
  • 44,990
  • 6
  • 37
  • 47
1

You could use C++/CLI to create wrapper classes.

Yochai Timmer
  • 46,349
  • 23
  • 142
  • 181
1

You can also use SWIG.

Matthias
  • 15,384
  • 5
  • 37
  • 80