HighTechTalks DotNet Forums  

Marshal struct with array of other struct (MyStruct[X])

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Marshal struct with array of other struct (MyStruct[X]) in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Cyril
 
Posts: n/a

Default Marshal struct with array of other struct (MyStruct[X]) - 11-16-2005 , 01:39 PM






Hello,

I have a problem to marshal a structure that contains an array of an
others struct. This array is an array size fixed (MyStruct[2] myStructs
and not MyStruct *myStructs).
For example :

C declaration :
struct Point {
int x;
int y;
}

struct Line {
Point[2] points;
int id;
}

For the C# declaration, I have try this declaration but this don't work
:
[StructLayout(LayoutKind.Explicit)]

public struct Point
{
[FieldOffset(0)] public int x;
[FieldOffset(4)] public int y;
}

[StructLayout(LayoutKind.Explicit)]
public struct Line
{
[FieldOffset(0)] [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Point[] points;
[FieldOffset(8)] public int id;
}

I have try other declaration but I haven't find solution.
If you have solution or some councils please tell me.

Thanks,
Cyril

PS : You can send the VB.Net solution too... :-)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.