Har*_*y13 3 c# pinvoke marshalling
是否可以在使用自定义封送拆收器的结构上使用Marshal.SizeOf()?
例如:
struct Abcde {
public int test1;
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MyCustomMarshaler)]
public string customString1;
}
Run Code Online (Sandbox Code Playgroud)
如果我打电话:
var size = Marshal.SizeOf(typeof(Abcde));
Run Code Online (Sandbox Code Playgroud)
抛出一个异常,表示无法计算有意义的大小或偏移量。我注意到ICustomMarshaler有一个名为GetNativeDataSize()的方法,但是无论我在那里返回什么都会抛出异常。
| 归档时间: |
|
| 查看次数: |
487 次 |
| 最近记录: |