So in my c++.dll file i got the following function:
DLL void GetUserPass(char* &userName, char* &passWord)
{
userName = "ceva";
passWord = "altceva";
}
Now I want to call this from c# but it gives me an error:
[DllImport("myDLL.dll")]
private static extern void GetUserPass(ref string userName, ref string passWord);
static void f()
{
string userName ="";
string passWord ="";
GetUserPass(ref userName, ref passWord);
}
And the error is:
A call to PInvoke function 'Download FTP Archive!Download_FTP_Archive.Program::GetUserPass' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Should I try in C++ dll file something like:
using std::string;
DLL void GetUserPass(string &userName, string &passWord)
{
userName = "ceva";
passWord = "altceva";
}