PC Review


Reply
Thread Tools Rate Thread

Convert C# struct to VARIENT

 
 
New Member
Join Date: Nov 2009
Posts: 1
 
      26th Nov 2009
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert struct to byte[] Paul Jarvis Microsoft C# .NET 3 21st Jan 2008 09:34 PM
Re: convert struct to byte[] Paul Jarvis Microsoft C# .NET 2 21st Jan 2008 08:13 PM
How would I convert this struct? Angel Microsoft C# .NET 5 11th Mar 2004 08:58 PM
Re: Convert byte[] from socket to struct Nick Wienholt Microsoft Dot NET Framework 0 21st Aug 2003 05:59 AM
Convert Struct to byte[] TJO Microsoft C# .NET 2 26th Jul 2003 04:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 AM.