tags:

views:

55

answers:

3

I got the next c function:

long _stdcall _MakePipeString(char *szOut, long nOutChars, const char *szXmlFile, long nOptions);

And I try to use pInvioke like this:

[DllImport("diXo10.dll")]
public static extern long _MakePipeString(out StringBuilder szOut, out long nOutChars, string szXmlFile, long nOptions);

But i get null in the ouput variable szOut.

Am I doing wrong?

Please help.

A: 

Have you tried:

[DllImport("diXo10.dll")]
public static extern long _MakePipeString([MarshalAs(UnmanagedType.LPStr)] out String szOut, out long nOutChars, [MarshalAs(UnmanagedType.LPStr)] string szXmlFile, long nOptions);

Note that you may also have to specify whether you expect ANSI or Unicode(UTF16) characters, for instance by using LPTStr/LPWStr instead of LPStr or on the DllImport attribute.

Lucero
A: 

try without the out parameter.

see here.

najmeddine
+1  A: 

In additions to what others have said, change the longs to ints on the C# side.

Mattias S