如何从C#调用C ++函数?

时间:2021-11-23 04:19:10

How can I call a C++ function from C# .NET?

如何从C#.NET调用C ++函数?

2 个解决方案

#1


6  

  1. compile the C++ function into a dll and use P/Invoke

    将C ++函数编译为dll并使用P / Invoke

    or

  2. compile the C++ function into a C++/CLI assembly, wrap in a managed C++ class, and then treat like any other assembly (add a reference, use a using statement and call the class)

    将C ++函数编译为C ++ / CLI程序集,包装在托管C ++类中,然后像任何其他程序集一样处理(添加引用,使用using语句并调用该类)

#2


0  

Or

Create a COM wrapper and then reference it from .NET

创建一个COM包装器,然后从.NET引用它

#1


6  

  1. compile the C++ function into a dll and use P/Invoke

    将C ++函数编译为dll并使用P / Invoke

    or

  2. compile the C++ function into a C++/CLI assembly, wrap in a managed C++ class, and then treat like any other assembly (add a reference, use a using statement and call the class)

    将C ++函数编译为C ++ / CLI程序集,包装在托管C ++类中,然后像任何其他程序集一样处理(添加引用,使用using语句并调用该类)

#2


0  

Or

Create a COM wrapper and then reference it from .NET

创建一个COM包装器,然后从.NET引用它