vb 中定义的struct如下:
Type QWAY_CCB ccbcmd As Byte
ccbdata(256) As ByteEnd Type
请问我在C#中如何定义和引用呢?谢谢
Type QWAY_CCB ccbcmd As Byte
ccbdata(256) As ByteEnd Type
请问我在C#中如何定义和引用呢?谢谢
解决方案 »
- C#实现电脑定时开关机的源码
- 正则表达式语法问题
- 使用DataSetHelper,对DataSet进行Group By时,可以对手动加入的数据进行Group By,而不能对从数据库或xml文件中加入的数据进行Group By
- 求解答树节点问题
- 怎样使DataGridView里满足某些条件的行的背景显示为红色?
- 关于文件夹重命名的问题??急!!!!!!!!!!!!!
- 请问一下MCAD和MCSD的权威性有多高???
- vs2003和vs2005中字符集有什么变化?
- 高分求C#下多线程下载原理和代码
- VS打开C#程序,如何添加图片所在的文件夹的路径
- 电子签名的制作!请教,分另加!
- 重写DataGridColumnStyle类后的DataGridComboBoxColumn的问题》
{
public Byte ccbcmd ;
public Byte[] ccbdata;
}
fib = new int[100]; // create a 100-element int array
{
public Byte ccbcmd ;
public Byte[] ccbdata;public QWAY_CCB()
{
ccbdata = new Byte[100];
}}
那你把结构名和数组大小的对应关系保存到xml或者创建资源文件,然后在程序中调用。
结构这样定义:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct QWAY_CCB
{
public byte ccbcmd;
[MarshalAs(UnmanagedType.ByValArray , SizeConst = 256)]
public byte[] ccbdata;
}我现在用的vs2005,有好多以前支持的东西现在都不行了。比如 QWAY_CCB qway_ccb;
int ret = AB_GW_RcvMsg(node, qway_rcv);
编译时提示qway_ccb变量没有赋值,于是我改为
QWAY_CCB qway_ccb = new QWAY_CCB();
int ret = AB_GW_RcvMsg(node, qway_rcv);
可以编译,但运行有错。提示:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. AB_GW_RcvMsg函数是个API函数:
private static extern int AB_GW_RcvMsg(long Gateway_ID, QWAY_CCB ccb);
问题可能出在
public byte[] ccbdata; 的定义上吧
Type QWAY_CCB ccbcmd As Byte
ccbdata(256) As ByteEnd Type
{
byte ccbcmd;
byte[] ccbdata;
}
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.请问上面的提示错误是什么错误?