I’m working on an inherited project that includes a C++ project which is successfully compiled to .exe. Now I want to try and integrate this project to a .NET form so I want to have it as a DLL (from what I’ve read it seems easier to do that if I use dll instead of exe) so I want to compile my C++ project to .DLL. I tried by right clicking on the project and making adjustment on the properties, but even though I choose .dll option when I rebuild the project I still get exe file.
I’m working on an inherited project that includes a C++ project which is successfully
Share
Here are the three “cleanest” options:
Create a C++/CLI (also called “Mangaged C++) wrapper around your C++ code to expose the functions as class methods. Then you can call these methods from C# just as you would a C# class.
Create a COM wrapper around your C++ functions. Very similar to creating a CLI wrapper, but can be used in non-.NET environments as well (VBA, for example)
Call your C++ DLL using P/Invoke. This requires the least C++ coding but can also tricky to get the interop correct, especially if you’re marshaling structures or other complex data types.