Reputation: 192
I want to create a dll from a C++ code and the use it in C#. Is there a solution of creating COM object from C++ ?
I don't want to use System.Runtime.InteropServices
.
Many thanks
Upvotes: 0
Views: 3957
Reputation: 6582
There are 3 ways to go about it.
1) Use PInvoke from C# to call into native methods.
2) Use C++-CLI to create a layer that exposes native functionality to C#. This is my recommended approach performance wise.
3) Write the C++ dll as a COM object and access from C#. Requires COM knowledge and hence developement cost.
Upvotes: 1
Reputation: 1401
you can use ATL , it too easy and you just have to register the dll . after that you can use it in all c# programms
Upvotes: 0
Reputation: 56956
You can write COM directly (see @Darin Dimitrov's answer), but you can also use ATL. My favorite solution to expose C++ code to C# (without COM though) is to use C++/CLI.
Upvotes: 4
Reputation: 1038710
Of course that you can write COM+ objects with C++. Here's a tutorial.
Upvotes: 4