gpt4 book ai didi

c# - 从 C# 代码调用 C++ native dll

转载 作者:行者123 更新时间:2023-11-30 02:04:14 25 4
gpt4 key购买 nike

我编写了完整的 native C++ 代码 dll,我想使用 P/Invoke 通过 C# 代码调用他的方法。我是否需要为此更改 native dll 的属性?

最佳答案

P/Invoking 需要 stdcall 约定。因此,请查看您的所有函数声明是否都以 __stdcall 开头。否则堆栈会损坏。

另请参阅 PInvokeStackImbalance C# call to unmanaged C++ function

关于c# - 从 C# 代码调用 C++ native dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10899200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com