interop for string[] array



The P/I function ADsBuildVarArrayStr works. When I look at the IL, no heavy Marshal code is done. I even suspect, that a pointer is passed to the array and that the array even not is pinned.

But when it comes to passing a string[] array through a struct, it does not work. Are there any secrets? (I'm using .NET 2.0)

sample what I would like to pass to a win32 function

struct blah
{
int cElements;
string [] elements
}



[DllImport("Activeds.dll", SetLastError = false, CharSet = CharSet.Unicode)]

public static extern int ADsBuildVarArrayStr(// [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)]
string[] lppPathNames,
int arrayLen,
[MarshalAs(UnmanagedType.Struct)]
out object varArray);


newarr [mscorlib]System.String
stloc.s CS$0$0000
ldloc.s CS$0$0000
ldc.i4.0
ldstr "hoi"
stelem.ref
ldloc.s CS$0$0000
: ldc.i4.1
ldstr "doei"
: stelem.ref
ldloc.s CS$0$0000
: stloc.1
ldloc.1
ldc.i4.2
ldloca.s bla
call int32 NWCNameTranslate::ADsBuildVarArrayStr(string[], int32, object&)



.



Relevant Pages

  • (patch for Bash) regex conditional tests
    ... 'regex' are returned in array variable SUBMATCH. ... Skipping of positional parameters, array elements, string ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: passing char arrays by reference
    ... I want to pass an array of strings to a function: ... int stuff{ ... stuff is an incompatible pointer type. ... string type; a "string" is a data format, ...
    (comp.lang.c)
  • Re: String of numbers into to array of numbers
    ... then read that string and have the string show the ... individual numbers as in an array. ... int arryCnt = 0; ... qStr= cStr.substring); ...
    (comp.lang.java.help)
  • PInvoke and marshalling question (on .net cf 1.1)
    ... using that to fill a managed byte array. ... want to have fixed size string arrays as some of the fields. ... Dim len As Integer = 0 ... Public AddressLength As Int32 ' 400 ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: PInvoke and marshalling question (on .net cf 1.1)
    ... using that to fill a managed byte array. ... want to have fixed size string arrays as some of the fields. ... Dim len As Integer = 0 ... Public AddressLength As Int32 ' 400 ...
    (microsoft.public.dotnet.framework.compactframework)