HighTechTalks DotNet Forums  

In .net code, how to declare a struct with safearray defined in CO

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


Discuss In .net code, how to declare a struct with safearray defined in CO in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?Um9iaW5aaG91?=
 
Posts: n/a

Default In .net code, how to declare a struct with safearray defined in CO - 08-28-2007 , 06:48 AM






In COM,
struct Data
{
BSTR Name;
SAFEARRAY(struct Point) Points
};
struct Point
{
double X;
double Y;
double Z;
}
HRESTUL test( struct Data)
if I want to pass struct Data to COM, how can declare a simlar struct in
..net code.
my try in .net
[StructLayout(LayoutKind.Sequential)]
struct Data
{
[MarshalAs(UnmanagedType.BStr)]
string Name;
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_RECORD)]
SAFEARRAY(struct Point) Points
}
[StructLayout(LayoutKind.Sequential)]
struct Point
{
double X;
double Y;
double Z;
}
but I alway encounter a invalid argument exception.
if I change to
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
SAFEARRAY(struct Point) Points
the address of Points is always null in COM sever.

Does any one has any ideas?
Thanks
Robin

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.