I have a c++ plus method that generates a value. i am calling this method from a c# application.
The C++ method is like this:
extern "C" REGISTRATION_API char * generate(char dIn[],char dOut[])
The generate
method returns an array of chars (sOut[]=returnvalue; return sOut;
)
Now I'm calling this method from my c# app:
[DllImport("mydll.dll")]
static extern string generate(string sIn, string sOut);
As you can see, the return type in c# is string
. What is happening is that the returned value in c# is not correct and it is corrupted. (The value is correct inside the generate
method, but whenever i call it from c# to extract it, i get some erroneous value.)
Is it OK that my method in C# has a string
return value while in c++ it's a char*
?
Please share your comments, it is urgent, thanks.