Null reference exception when feeder detects paper but is unable to pull it

Issue #36 resolved
Erasmo Simó created an issue

This happens when a scanner with feeder detects that it has paper but is unable to pull the paper (not when paper jams).

I've only tried with a "Plustek Smartoffice PS282" scanner. It is a very rare occurrence but it happens. To reproduce it I must basically hold the paper so it doesn't go into the scanner, but it has happened on its own.

I'm using version 3.2.7 from nuget (Saturday, February 14 2015)

Here is the stacktrace:

   at NTwain.Triplets.PendingXfers.EndXfer(TWPendingXfers pendingXfers) in c:\Users\Eugene\Desktop\Code\NTwain\NTwain\Triplets\DGControl\DGControl.PendingXfers.cs:line 23
   at NTwain.Internals.TransferLogic.DoTransferRoutine(ITwainSessionInternal session) in c:\Users\Eugene\Desktop\Code\NTwain\NTwain\Internals\TransferLogic.cs:line 106
   at NTwain.TwainSession.HandleSourceMsg(Message msg) in c:\Users\Eugene\Desktop\Code\NTwain\NTwain\TwainSessionInternal.cs:line 291
   at NTwain.TwainSession.IsTwainMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) in c:\Users\Eugene\Desktop\Code\NTwain\NTwain\TwainSessionInternal.cs:line 246
   at NTwain.Internals.WindowsHook.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in c:\Users\Eugene\Desktop\Code\NTwain\NTwain\Internals\WindowsHook.cs:line 45
   at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at NTwain.Internals.InternalMessageLoopHook.<>c__DisplayClassc.<Start>b__8() in c:\Users\Eugene\Desktop\Code\NTwain\NTwain\Internals\InternalMessageLoopHook.cs:line 45
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

The exception is not catch thus terminating the application.

Comments (3)

  1. Eugene Wang repo owner

    I can't reproduce with the scanner I'm testing since it'll just keep the roller going. I'd appreciate it if you can test on yours and let me know which object is being null. PendingXfers.EndXfer() call should not encounter any null parameter at the transferring state.

  2. Erasmo Simó reporter

    I found the problem. I was closing the TwainSession on TransferError(my mistake). So the CurrentSource was null when EndXfer was called.

  3. Log in to comment