Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2004

Tip: Looking for answers? Try searching our database.

Marshalling problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel - 14 Jun 2004 07:09 GMT
Hi, I'm having trouble converting a C++ structure to C#.  This is the
definition of the C++ structure:

struct PLUGIN_PUBLISH_LIST

{

int nCount;

char sName[50][128];

char sValue[50][128];

char sHelp[50][256];

};

So basicly its a array of 50 strings for each, with a 128/256 character
array in each.  So in C# I can use the MarshalAs attribute todo one or the
each (UnmanagedType.ByValTStr / UnmanagedType.ByValArray  + SizeConst to
specify the size), but I cant work out how todo both.  Can someone help me
work this out?  Worst case scenario I guess I could just put 50 strings for
each in my structure but I really don't want to go there.  Thanks in
advance. :)

Dan
chaor - 17 Jun 2004 12:18 GMT
you can treat the two dimension array as single dimension array.

like this:
[ StructLayout( LayoutKind.Sequential)]
public  struct  PLUGIN_PUBLISH_LIST

{

int nCount;

[MarshalAs(UnmanagedType.ByValArray,SizeConst=6400)]
char[] sName;

[MarshalAs(UnmanagedType.ByValArray,SizeConst=6400)]
char[] sValue;

[MarshalAs(UnmanagedType.ByValArray,SizeConst=12800)]
char[] sHelp;

};

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.