Invoke Native C++ DLL from .NET Code
Solution 1. (Explicit) P/Invoke
Solution 2. Dynamic P/Invoke
Solution 3. Implicit P/Invoke (Use a C++/CLI wrapper)
Solution 4. Convert C++ DLL to a COM server, and call it from .NET code through .NET-COM interop
Solution 1. (Explicit) P/Invoke
Samples:- CppDynamicLinkLibrary (a native C++ DLL module that exports global data, functions and classes)
- CSPInvokeDll (a C# application that P/Invokes the functions exported by CppDynamicLinkLibrary)
- VBPInvokeDll (a VB.NET application that P/Invokes the functions exported by CppDynamicLinkLibrary)
Download the All-In-One Code Framework (Library) package.
Solution 2. Dynamic P/Invoke
Samples:- CppDynamicLinkLibrary (a native C++ DLL module that exports global data, functions and classes)
- CSLoadLibrary (a C# application that dynamically P/Invokes the functions exported by CppDynamicLinkLibrary)
- VBLoadLibrary (a VB.NET application that dynamically P/Invokes the functions exported by CppDynamicLinkLibrary)
Download the All-In-One Code Framework (Library) package.
Solution 3. Implicit P/Invoke (Use a C++/CLI wrapper)
Samples:- CppDynamicLinkLibrary (a native C++ DLL module that exports global data, functions and classes)
- CppCLINativeDllWrapper (a C++/CLI wrapper of the native C++ DLL CppDynamicLinkLibrary)
- CSCallNativeDllWrapper (a C# application that invokes CppDynamicLinkLibrary through CppCLINativeDllWrapper)
- VBCallNativeDllWrapper (a VB.NET application that invokes CppDynamicLinkLibrary through CppCLINativeDllWrapper)
Download the All-In-One Code Framework (Library) package.
Solution 4. Convert C++ DLL to a COM server, and call it from .NET code through .NET-COM interop
Samples:- ATLDllCOMServer (a native C++ DLL converted to an in-process COM server)
- CSCOMClient (a C# application that invokes the C++ in-process COM server ATLDllCOMServer)
- VBCOMClient (a VB.NET application that invokes the C++ in-process COM server ATLDllCOMServer)
Download the All-In-One Code Framework (COM) package.