C++/CLI and C#: Writing Managed Wrappers for Native Code

Less than a minute to read

The following article is going to go more in-depth into what is required to write a managed wrapper for a native library or application. It requires making use of an intermediary language called C++/CLI, which syntactically could be simply described as a hybrid between C++ and C# and requires using the /clr or /clr:pure compiler argument when compiling a native library using MSVC.

Syntax

The following section describes the syntax for some core types in C++/CLI.

The Rules

The following section outlines what the rules are when developing libraries that use a combination of C++/CLI.

  1. Natively declared and defined classes (e.g. using pure C++ syntax) cannot be consumed or referenced directly from C# code.

Consuming from C#

The following section outlines what is required for consuming a library that is written in C++/CLI.

Resources

Find below a few interesting links that might help you.



Comments