I am trying to learn about marshaling structures and DLL's. I'm following this example.
The code builds and compiles just fine. But when I run it, the lines where the call to the function is returned; it makes the call to the function from the DLL, goes through it, but when it returns the result to the main program, it throws this exception:
A call to PInvoke function **** 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.
I read about the problem and it says I have to verify that the calling conventions I am using are the same. Well, I'm not using any so what's the deal?
The thing is, if I hit "Continue", the code executes fine until the next function return (the first time it's for GetDistance and the second time is for InitLocation). So I don't get it.
The code works, but I want to resolve this annoying exception