问题描述
我正在尝试更改此内容:
[StructLayout(LayoutKind.Sequential,Pack = 1)]
public class Frame : BinaryStruct
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst = 256)]
public ulong[] array1 = new ulong[256];
[MarshalAs(UnmanagedType.ByValArray,SizeConst = 256)]
public ushort[] array2 = new ushort[256];
[MarshalAs(UnmanagedType.ByValArray,SizeConst = 16)]
public ushort[] array3 = new ushort[16];
[MarshalAs(UnmanagedType.I8,SizeConst = 16)]
public long[] iP = new long[16];
public Frame()
{
array1 = new ulong[256];
array2 = new ushort[16];
array3 = new ushort[256];
iP = new long[16];
}
}
通过字节数组:
public virtual byte[] ToArray()
{
int size = Marshal.SizeOf(this);
IntPtr ptr = Marshal.AllocHGlobal(size);
Marshal.StructuretoPtr(this,ptr,false);
byte[] array = new byte[size];
Marshal.copy(ptr,array,size);
Marshal.FreeHGlobal(ptr);
return array;
}
它可以不使用
[MarshalAs(UnmanagedType.I8,SizeConst = 16)]
public long[] iP = new long[16];
long iP =新的IpAddrees(...)。地址
我认为问题是UnmanagedType。I8我正在尝试I4,但是它不起作用。
错误:
Managed Debugging Assistant 'NonComVisibleBaseClass':' A QueryInterface method call was made requesting the COM-visible class interface of the 'Frame' managed class. However,since this class is derived from COM invisible 'WS.BinaryStruct',the call to QueryInterface will fail. This prevents COM version control rules from
限制COM不可见的基类。 '
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)