Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#System.Runtime.InteropServices.Marshal.PtrToStructure不断出现“;System.ExecutionEngineeException”;错误消息_C# - Fatal编程技术网

C#System.Runtime.InteropServices.Marshal.PtrToStructure不断出现“;System.ExecutionEngineeException”;错误消息

C#System.Runtime.InteropServices.Marshal.PtrToStructure不断出现“;System.ExecutionEngineeException”;错误消息,c#,C#,我做错了什么?不清楚在StructureToPtr或PtrToStructure上哪里会出现错误?您能否在使用PtrToStructure()执行相反操作的地方发布代码,即将数据从非托管封送到托管封送。 Node { public object key; public object value; } int[] cache = new int[200*8]; int[] PtrList = new int[200]; int m_node_length = System.Runtime

我做错了什么?

不清楚在StructureToPtr或PtrToStructure上哪里会出现错误?您能否在使用PtrToStructure()执行相反操作的地方发布代码,即将数据从非托管封送到托管封送。
Node
{
  public object key;
  public object value;
}

int[] cache = new int[200*8];
int[] PtrList = new int[200];
int m_node_length = System.Runtime.InteropServices.Marshal.SizeOf(typeof(Node));

fixed (byte* array = m_cache)
{
    for(int i = 0; i < PtrList.Length; i++)
        PtrList[i] = (int)new IntPtr(array + i * (m_node_length));
}
Node n = new Node();
n.key = a // a is int number
n.value = b // b is int number
IntPtr p = (IntPtr)PtrList[X]; // X >= 0 & X < 200
System.Runtime.InteropServices.Marshal.StructureToPtr(n, p, true);
The exception of the "System.ExecutionEngineException" type is not handled in the mscorlib.dll