1

Is it possible to use a C++ API (series of Header files and CPP files) in a C# project?

Maybe its possible to compile these files into .obj or .lib files and include them in the Visual C# project? Something similar is done for Crypto++.

If it is possible, are there any drawbacks from this?

Context and import information:

  • The C++ API is called NWCreate and is developed by Autodesk Navisworks
  • I am using Microsoft Visual Studio C# 2010
  • We have a large existing code base in C# where much of the operations we will perform in the navisworks plugin are already coded in C# (from other Autodesk projects we have produced). So having to rewrite all those operations in C++ is very much reinventing the wheel.
JSDBroughton
  • 3,966
  • 4
  • 32
  • 52
Mack
  • 179
  • 3
  • 13
  • This is best solution. It worked well for me http://stackoverflow.com/a/34541336/5732839 – Croko Dec 31 '15 at 05:12

1 Answers1

1

at least , you have 2 method to invoke C/C++ API from .NET:

  • Compile the C/C++ API as dll, then use PInvoke to call it from .NET
  • Use Managed C++ (VC++), then use IJW to wrap the native code, IJW will generate managed code that can call directly from .NET
ray_linn
  • 1,382
  • 10
  • 14