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)]
publicstructsegmentInfo_st
{ publicint nSegID;
publicint nSegFillOrder;
publicint nSelectFlag;
publicint nGraficDispFlag;
publicint nImgTextDispFlag;
publicint nScalBarDispFlag;
publicint nShutterDispFlag;
publicint nSummaryFlag;
publicint nNoteFlag;
publicArrayList segList;
}
I tried it to convert to VARIENT using Marshal.GetNativeVariantForObject
like
IntPtr resultVar;
segmentInfo_st segInfo = newsegmentInfo_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
|