You can invoke a C# or a managed .Net dll from a Native application written in VC++ or C++ in several ways. Here are the three main ways you can use to achieve this.
- Use a C++/CLI wrapper
- Host CLR (Common Language Runtime)
- Convert .NET assembly to a COM server, and call it from C++ through .NET-COM interop
1. Use of C++/CLI Wrapper
C++/CLI is a self-contained, component-based dynamic programming language that, like C# or Java, is derived from C++. You can say that C++/CLI is to C++ as C++ is to C. In essence, it is how you do .NET programming using C++ rather than using C# or VB or several other languages. To learn more about C++/CLI refer to the following articles.
- Pure C++: Hello, C++/CLI
- C++: The Most Powerful Language for .NET Framework Programming
- Best Practices for Writing Efficient and Reliable Code with C++/CLI
2. Host CLR
Hosting CLR is basically using entire CLR as a library and loading it into your application host process. This will allow your application to contain the whole CLR virtual machine and loads assemblies and run managed code with in the virtual machine. Once you load the CLR into your application, the host process is now responsible for defining the application domains with in the process and executing user code within these domains. For more information related about CLE hosting, refer to this CLR Inside Out article on MSDN.
Related titles:
- How to invoke a .Net assembly from a Native application?
- How to invoke a VB.Net dll from a C++ application?
- How to use a managed dll in a native application?
- (3) Comments
- Tags: .Net, C#, VB.Net, VC++
