【发布时间】:2014-07-02 18:49:50
【问题描述】:
我有一个像这样声明的 C# 结构:
public struct AdvertisementData {
public byte SomeId;
[MarshalAs(UnmanagedType.LPArray , SizeConst = 12)]
public byte[] AnArray;
}
它是 C++ 对应物:
struct AdvertisementData {
uint8_t SomeId;
uint8_t AnArray[12];
};
当我尝试将上述结构的堆栈分配实例的引用从 C++ 发送到 C# 时,我得到:“字节 [] 类型的结构字段不能编组为 LPArray。” 知道我做错了什么吗?
【问题讨论】:
-
你能用
SafeArray试试吗?
标签: c# arrays mono marshalling fixed-width