I got an ArgumentException while calling
Marshal.GetNativeVariantForObject(segInfo, resultVar);
The exception detailis {"Value does not fall within the expected range."}
I have a C# struct as follows
[StructLayout(LayoutKind.Sequential)]
public struct segmentInfo_st
{ public int nSegID;
public int nSegFillOrder;
public int nSelectFlag;
public int nGraficDispFlag;
public int nImgTextDispFlag;
public int nScalBarDispFlag;
public int nShutterDispFlag;
public int nSummaryFlag;
public int nNoteFlag;
public ArrayList segList;
}
I tried it to convert to VARIENT using Marshal.GetNativeVariantForObject
like
IntPtr resultVar;
segmentInfo_st segInfo = new segmentInfo_st();
segInfo.nSegID = 1;
int sz = Marshal.SizeOf(typeof(segmentInfo_st));
resultVar = Marshal.AllocCoTaskMem(sz);
Marshal.GetNativeVariantForObject(segInfo, resultVar);
Expecting early help .
Thanks & regards,
Dileep S
Marshal.GetNativeVariantForObject(segInfo, resultVar);
The exception detailis {"Value does not fall within the expected range."}
I have a C# struct as follows
[StructLayout(LayoutKind.Sequential)]
public struct segmentInfo_st
{ public int nSegID;
public int nSegFillOrder;
public int nSelectFlag;
public int nGraficDispFlag;
public int nImgTextDispFlag;
public int nScalBarDispFlag;
public int nShutterDispFlag;
public int nSummaryFlag;
public int nNoteFlag;
public ArrayList segList;
}
I tried it to convert to VARIENT using Marshal.GetNativeVariantForObject
like
IntPtr resultVar;
segmentInfo_st segInfo = new segmentInfo_st();
segInfo.nSegID = 1;
int sz = Marshal.SizeOf(typeof(segmentInfo_st));
resultVar = Marshal.AllocCoTaskMem(sz);
Marshal.GetNativeVariantForObject(segInfo, resultVar);
Expecting early help .
Thanks & regards,
Dileep S