I have the following C++ function and C# p/invoke decleration:
//C#
[DllImport("capture.dll", EntryPoint = "setup")]
public static extern void captureSetup(int rr);
//C++
extern "C" {
__declspec(dllexport) void setup(int rr)
But I am getting an error about a p/invoke unbalanced stack likely caused by the managed signature not matching the unmanaged signature.
Can anyone see what is wrong with this?
It’s a calling convention mismatch. The C++ code uses
cdeclby default but the C# assumesstdcall. You need to make them match, e.g.