Calling C++ function from C#
Hi all,
I am new to C#. So not able to find why the my code is failing:
//hpp file
/* Arguments:
* IN: data - data to parse
* data_length - length of data to parse
* OUT: result_length - length of result
* error_code - error code if the function fails (0 in success)
*
* Return value: pointer to result buffer
* NULL - if operation fails (error_code is set to the error code)
*
*/
PARSER_API unsigned char *GetResult(unsigned char *data,
unsigned short data_length,
unsigned short *result_length,
unsigned short *error_code);
//C# file
[DllImport("Parser.dll", EntryPoint="GetResult")]
static extern byte[] GetResult(
byte[] data,
UInt16 data_length,
[Out()] UInt16 signature_length,
[Out()] UInt16 error_code);
public byte[] GetResult()
{
byte[] str=...
...
byte[] res = GetSignature(str, datalen, reslen, errnum);
return res;
}
I am getting error as "Can not marshal return value."
Could somebody please help me to figure out what is the problem.
Thanks in advance,
Sri