P
Pollux
I'm having a problem with something I thought was quite simple.
I have a function in a C DLL. Let's call it SomeFunction. This is the
prototype for SomeFunction:
void SomeFunction(char * anArrayOfChars);
where anArrayOfChars is an out parameter.
I thought all I had to do was declare it as follows:
[DllImport("someDLL", CharSet = CharSet.Auto)]
public static extern void SomeFunction(StringBuilder sBuf)
and within the Main function call it like that:
StringBuilder sBuf = new StringBuilder(128);
SomeFunction(sBuf);
And I should have an sBuf that was filled by some function.
Unfortunately, I'm getting the following exception:
Object Reference not set to an instance of an object. Any ideas what I'm
doing wrong?
In case you wonder, SomeFunction just does a strcpy(anArrayOfChars,
"Hello, World!);
Thanks in advance.
I have a function in a C DLL. Let's call it SomeFunction. This is the
prototype for SomeFunction:
void SomeFunction(char * anArrayOfChars);
where anArrayOfChars is an out parameter.
I thought all I had to do was declare it as follows:
[DllImport("someDLL", CharSet = CharSet.Auto)]
public static extern void SomeFunction(StringBuilder sBuf)
and within the Main function call it like that:
StringBuilder sBuf = new StringBuilder(128);
SomeFunction(sBuf);
And I should have an sBuf that was filled by some function.
Unfortunately, I'm getting the following exception:
Object Reference not set to an instance of an object. Any ideas what I'm
doing wrong?
In case you wonder, SomeFunction just does a strcpy(anArrayOfChars,
"Hello, World!);
Thanks in advance.