This question was
closed Jul 31, 2016 at 01:57 PM by
zachasplays for the following reason:
The question is answered, right answer was accepted
Question by
zachasplays · Jul 30, 2016 at 11:17 AM ·
unity 5bugc++dllimport
DLL Import Errors
Hello,
I'm really new to Unity and I try to load a c++ .dll into my unity script.
Heres my Problem.
The C++ Projekt have one Method in the .cpp:
bool Connect(string c_szAddr) {
return true;
}
And thats the .h Part:
extern "C" { __declspec(dllexport) bool Connect(string c_szAddr); }
Now I load the dll and try to pass a string value to my C++ Method:
[DllImport("LoginRess")]
private static extern bool Connect(string c_szAddr);
public void __cplusplusconnect(string name, string password)
{
Debug.Log(Connect(CONFIG.IP));
}
If I use this function...I get a strange error:
And the Unity Editor Dies after this^^. The Strange Thing is, when I use my Method without any param...theres no error. Thank you for any help.
unity-2016-07-30-13-12-37.png
(11.3 kB)
Comment
Answer by zachasplays · Jul 31, 2016 at 01:56 PM
I have found the problem
bool Connect(string c_szAddr) {
return true;
}
I don't know why, but it CAN'T get the param as a string. Here it must be const char*...