【发布时间】:2016-11-15 02:01:31
【问题描述】:
我正在尝试读取通过调用 C# 中的 dll 函数创建的数组。当我打印出数组的内容时,它实际上充满了垃圾。
我怀疑这是因为我错误地将const float** 编组为out IntPtr。你如何正确编组const float**?
DLL C++ 接口
int Foo(void *objPtr, uint64_t *resultLen, const float **result);
DLL 导入声明
[DllImport("foo.dll", CharSet = CharSet.Auto)]
public static extern int Foo(IntPtr objPtr, out ulong resultLen, out IntPtr result);
调用代码
IntPtr objPtr = getObj();
IntPtr result;
ulong resultLen;
int output = Foo(objPtr, out resultLen, out result);
【问题讨论】:
-
显示了调用函数的示例 C++ 代码
标签: c# pinvoke marshalling