hpw
2007-06-14 13:41:56 UTC
Hi all,
i'm trying to use COM Interop to return an array of c# structures to
Native code.
I tried to marshall the Array as SAFEARRAY.
The structure:
[StructLayout(LayoutKind.Sequential)]
[ComVisible(true)]
public struct teststruct{
[MarshalAs(UnmanagedType.LPStr)]
public string string1;
[MarshalAs(UnmanagedType.LPStr)]
public string string2;
[MarshalAs(UnmanagedType.LPStr)]
public string string3;
[MarshalAs(UnmanagedType.SafeArray)]
public string[] parameters;
};
is given back via a function
[return: MarshalAs(UnmanagedType.SafeArray)]
public teststruct[]
GetTestStruct([MarshalAs(UnmanagedType.LPStr)]string strParam, int
iParam) ;
I've generated the TLB via tlbexp.exe and used the Objects in a C++
Program.
Other calls with string-arrays and int-arrays work find. But for this
particular case i get the following _com_error:
0x80028019 - Old format or invalid type library
I also tried to specifiy the SafeArraySubType.
No Effect.
Any Help would be appreciated
HPW
i'm trying to use COM Interop to return an array of c# structures to
Native code.
I tried to marshall the Array as SAFEARRAY.
The structure:
[StructLayout(LayoutKind.Sequential)]
[ComVisible(true)]
public struct teststruct{
[MarshalAs(UnmanagedType.LPStr)]
public string string1;
[MarshalAs(UnmanagedType.LPStr)]
public string string2;
[MarshalAs(UnmanagedType.LPStr)]
public string string3;
[MarshalAs(UnmanagedType.SafeArray)]
public string[] parameters;
};
is given back via a function
[return: MarshalAs(UnmanagedType.SafeArray)]
public teststruct[]
GetTestStruct([MarshalAs(UnmanagedType.LPStr)]string strParam, int
iParam) ;
I've generated the TLB via tlbexp.exe and used the Objects in a C++
Program.
Other calls with string-arrays and int-arrays work find. But for this
particular case i get the following _com_error:
0x80028019 - Old format or invalid type library
I also tried to specifiy the SafeArraySubType.
No Effect.
Any Help would be appreciated
HPW