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
  • 20,058
  • 51
  • 133
  • 197

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,362
  • 1
  • 30
  • 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
  • 46,413
  • 6
  • 36
  • 47
1

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

Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185
1

You can also use SWIG.

Matthias
  • 15,919
  • 5
  • 39
  • 84