|
Fortran中定义的结构体
!对象信息
type ObjectInfo
sequence
character(len=16):: ObjName !对象名称
integer(kind=4):: ObjState !对象状态 0(正常) 1(抛弃) 2(删除)
integer(kind=2):: ObjProperty !对象属性 1(通道对象) 2(表对象) 3(流对象)
integer(kind=2):: ObjSonProperty!对象子属性
integer(kind=4):: ObjOffsetD !对象数据体偏移量
integer(kind=4):: ObjBlockNumber!对象数据体占用磁盘的块数
integer(kind=4):: ObjCreateTime !对象产生的时间
integer(kind=4):: ObjEditTime !对象修改的时间
character(len=32):: Other !保留字节
end type ObjectInfo
C#中定义的结构体
/// <summary>
/// 对象信息
/// </summary>
[StructLayout(LayoutKind.Sequential,Pack =1)]
public struct ObjectInfo
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public char[] ObjName;
public int ObjState;
public short ObjProperty;
public short ObjSonProperty;
public int ObjOffsetD;
public int ObjBlockNumber;
public int ObjCreateTime;
public int ObjEditTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public char[] Other;
}
问题 C#调用Fortran的dll,传递单个结构体可以获取正确值,但是传递结构体数组的时候就会报错
|
|