C++ - C++/CLI - DotNet 6 interoperations
CSharpApp
is a dll which contains C# implementation for a library that will be used by unmanaged C++CppCliWrapper
is a dll wrapper written in C++/CLI forCSharpApp
which creates the adaption with the unmanaged C++ codeclient_app
is an unmanaged C++ application (executable) which takes use of theCSharpApp
through the use ofCppCliWrapper
In order to generate the CppCliWrapper.dll
and CppCliWrapper.lib
files, DLL_EXPORT
constant should be defined into Preprocessor Definitions
for all configurations:
CppCliWrapper
project propertiesC/C++
/Preprocessor
- Select
All Configurations
andAll Plaforms
at the top - In
Preprocessor Definitions
edit and appendDLL_EXPORT
to<different options>
; it wil result<different options>; DLL_EXPORT
- Press
OK
andOK
to close all dialogs
To find the necessary namespaces and classes, references to CppCliWrapper
should be added to client_app
:
client_app
project properties- Select
All Configurations
andAll Plaforms
at the top - Goto
VC++ Directories
- In
Include Directories
append..\CppCliWrapper
- Goto
Linker
/Input
- In
Additional Dependencies
appendCppCliWrapper.lib
at the end of the list
Cpp Dot Net Data Types Marshaling Interop through COM objects Interop through COM objects sample