Invoke .NET Assembly from Native C++ Code
Solution 1. Use a C++/CLI wrapperSolution 2. Host CLRSolution 3. Convert .NET assembly to a COM server, and call it from C++ through .NET-COM interop
Solution 1. Use a C++/CLI wrapper
Samples:
- CSClassLibrary (a C# class library)
- CppCLINETAssemblyWrapper (a C++/CLI wrapper of the C# class library CSClassLibrary)
- CppCallNETAssemblyWrapper (a native C++ application that invokes CSClassLibrary through CppCLINETAssemblyWrapper)
The native C++ sample application CppCallNETAssemblyWrapper calls the .NET class defined in the C# class library CSClassLibrary through the C++/CLI wrapper CppCLINETAssemblyWrapper.

Download the
All-In-One Code Framework (Library) package.
Solution 2. Host CLR
Samples:
- CSClassLibrary (a C# class library)
- CppHostCLR (a native C++ application that host CLR and load the .NET assembly CSClassLibrary)
The native C++ sample application CppHostCLR hosts CLR, instantiates a type in the .NET assembly CSClassLibrary.dll and calls its methods. Both
.NET Framework 1.x Hosting Interfaces and
.NET Framework 2.0 Hosting Interfaces are demonstrated in the code samples.

Download the
All-In-One Code Framework (Library) package.
Solution 3. Convert .NET assembly to a COM server, and call it from C++ through .NET-COM interop
Samples:
- CSDllCOMServer (a C# class library converted to an in-process COM server)
- CppCOMClient (a native C++ application that invokes the C# in-process COM server CSDllCOMServer)
The native C++ sample application CppCOMClient invokes the in-process COM server CSDllCOMServer that was converted from a C# class library.

Download the
All-In-One Code Framework (COM) package.
