开发者

Creating COM object from C++?

开发者 https://www.devze.com 2023-02-03 08:52 出处:网络
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 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.InteropService开发者_C百科s.

Many thanks


Of course that you can write COM+ objects with C++. Here's a tutorial.


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消