I got following errors when tried to calling .dll (made from delphi) function from unity3d C# code.
Here is pictures,
and errors says,
and .dll codes are,
So why error occurs and how to solve?
Thanks a lot!
Where you write
error = GetRequestResult(code);
you need to write
error = GetRequestResult(out code);
which is precisely what the second error message states.
Looking at your code, returning a PChar
from the Delphi DLL the way that you do is not compatible with your P/invokes. The P/invoke marshaller is assuming that your return values were allocated with CoTaskMemAlloc
and will call CoTaskMemFree
on the pointer that you return. That's going to lead to some problems somewhere down the line. I think you'll need to tackle that issue at some point but since it's not the subject of this question, I won't attempt to solve the problem here.