- C#调用C++的服务需要通过C++的DLL文件进行。
- 在编写C++的DLL时候,需要指定项目属性的导出为DLL和C++设置
- 在编写C#通信的时候需要DLL
[DllImport(@"Dll的文件地址", EntryPoint = "定义的方法")]
然后声明同类型的方法。注意是否需要传递指针。 - 如果需要传递指针,必须在C#中声明unsafe(并设置项目支持unsafe的选项,在项目属性中进行配置) 并使用fixed进行固定地址。
- 如果C++想要调用C#方法可以通过 delege进行声明,并进行设置调用代理后的方法。
- 在使用传递结构体时,需要对应的参数和名称相同。
LikeRainDay/CshapeGetCplugplugDemo
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
C# 调用C++编写的Dll文件。
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published