Using C# code in C++: CLI
C# codebase on other hand (old project) and the necessity to reuse its code in C++ (WCF, WIF, some SDKs are purely .NET) led our team to the question "how would we be able to reuse this code fast"?
Ideas of implementing pipe interface is too clumsy and finding the unmanaged alternatives of the WCF and WIF will take too much time.
And here the solution that come up: use the interim C++/CLI library which will use purely managed C# libraries on one hand and will expose purely unmanaged CPP interfaces on the other.
Here the sample project is:
CLIDemo solution contains three projects:
CSharpLib – pure C# assembly with one class we will use from CPP
CSharpLibCLR – C++/CLI wrapper for the CSharpLib
CLIDemo – purely unmanaged C++ console project using CSharpLibCLR as a statically linked library
CLIDemo is creating the interim class, subscribing to events and invoking events/receiving event callbacks using purely managed code.
Post a Comment