Might be a bit of noob question but it's something that's been getting me in a pickle for the past few hours (or days)...
I'm calling a method from a DLL in my code in .NET Framework 4.0
[DllImport("xeneth.dll")]
public static extern ErrorCode XC_GetFrame(Int32 h, FrameType type, ulong ulFlags, IntPtr buff, uint size);
and then using it here:
if (XC_GetFrame(myCam, XC_GetFrameType(myCam), 0, IntPtr.Zero, (uint)fs) != ErrorCode.E_NO_FRAME)
However, when I run this in .NET 4.0 I get a P/INVOKE error, however... running this in 3.5 does not trigger this error. After myself and another programmer have gone over the code we seem to have put it down to the IntPtr running differently on 4.0.
My application needs to run in .NET 4.0 as a couple of features required by the application are only available in 4.0 ...
Is there anything that maybe i'm overlooking or have simply forgotten to include?
Any thoughts are much appreciated!
Tom
Update:
Native Declaration:
virtual ErrCode XCamera::GetFrame(FrameType type, unsigned long ulFlags, void *buffer, unsigned int size)
Error: A call to PInvoke function 'DLLTest!DLLTest.Form1::XC_GetFrameType' 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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…