edsdk-wrapper icon indicating copy to clipboard operation
edsdk-wrapper copied to clipboard

pInvoke Stack Imbalance (Win10?) (CallingConvention?)

Open tlhintoq opened this issue 9 years ago • 2 comments

EDSDK from Canon: 2.15 (nov 2014) Canon T2i Dell i7 laptop, Win10x64

As downloaded: Camera.cs - Lines 701, 706 throw PInvokeStackImbalance exceptions.

EDSDKInvokes.CreateEvfImageRef
EDSDKInvokes.DownloadEvfImage

Details on both say The name '$exception' does not exist in the current context. The other calls in EDSDKInvokes to NOT throw this exception and seem to work as the live preview frames do arrive and display.

Running without debugging shows the frame still arrives and is visible in the sample EDSKDWrapper.UI project MainView.xaml window.

Eventually however even this fails with

... has stopped working."  Attaching the debugger then shows "Unhandled exception at 0x72DB3AA2 (clr.dll) in EDSDKWrapper.UI.exe: Stack cookie instrumentation code detected a stack-based buffer overrun.

I am running Windows 10 tech preview, so maybe that has something to do with it but so far everything that works in Win8.1 is same in Win10.

These seem to be the only calls in that file that are specifying CallingConvention If I remove that argument it seems to run fine and not throw the error:

        //[DllImport("EDSDK.dll", EntryPoint = "EdsCreateEvfImageRef", CallingConvention = CallingConvention.Cdecl)]
        [DllImport("EDSDK.dll", EntryPoint = "EdsCreateEvfImageRef")]
...
        //[DllImport("EDSDK.dll", EntryPoint = "EdsDownloadEvfImage", CallingConvention = CallingConvention.Cdecl)]
                [DllImport("EDSDK.dll", EntryPoint = "EdsDownloadEvfImage")]

ReturnValueManager.cs | Line 53 | HandleFunctinReturnValue Continuously throws exception ObjectNotReady- yet the frames are coming up pretty fast and at decent resolution for the last 20 minutes without crash.

tlhintoq avatar Mar 06 '15 16:03 tlhintoq

I ran into the same issue. The camera goes into an error state that requires you to power it down and restart your app. I am not sure what causes this yet. I have seen simultaneous calls to the API causes the camera to hang up. Ensure you use lock{} when making camera commands. The camera may be on auto shut down. You will also see the error, ObjectNotReady due to the camera displaying the image after taking a photo. Set the camera to no preview after photo capture and fetching live preview images throws no errors.

manit77 avatar Oct 18 '16 00:10 manit77

I'm running into the pinvoke-inbalance...

robertkjr3d avatar Nov 06 '20 15:11 robertkjr3d