3

I'm converting a MFC app in x64. This app has a few WPF controls/dialogs. The problem I have is, for a few users, displaying a WPF control/dialog does not work. I get this exception:

System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
   at System.Windows.Threading.Dispatcher.WndProcHook(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.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Threading.WaitHandle.WaitOneNative(SafeHandle waitableSafeHandle, UInt32 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
   at System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
   at System.Windows.Input.PenThreadWorker.WorkerCreateContext(IntPtr hwnd, IPimcTablet pimcTablet)
   at System.Windows.Input.TabletDevice.CreateContext(IntPtr hwnd, PenContexts contexts)
   at System.Windows.Input.TabletDeviceCollection.CreateContexts(IntPtr hwnd, PenContexts contexts)
   at System.Windows.Input.PenContexts.Enable()
   at System.Windows.Input.StylusLogic.RegisterHwndForInput(InputManager inputManager, PresentationSource inputSource)
   at System.Windows.Interop.HwndStylusInputProvider..ctor(HwndSource source)
   at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters)
   at System.Windows.Forms.Integration.ElementHost.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Integration.ElementHost.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The app than hangs for a few seconds and crashes.

Has anybody ever had similar problems with MFC/WPF in 64bit ?

Olivier
  • 67
  • 4
  • I've seen this message before using [Dispatcher.DisableProcessing Method](http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.disableprocessing.aspx) without using statement (meaning processing wasn't re-enabled). But I've no idea if my comment is helpful in your case. – LPL Sep 04 '13 at 19:47
  • Yeah thanks. By looking at the [Dispatcher](http://msdn.microsoft.com/en-us/library/System.Windows.Threading.Dispatcher.aspx) class code, I concluded that the only way it could throw as it did is with a previous call to the [Dispatcher.DisableProcessing](http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.disableprocessing.aspx) method but I don't directly call it. Does anybody know of a case where it could be called indirectly by the Framework ? – Olivier Sep 04 '13 at 20:29
  • 1
    The problem has nothing to do with MFC. I can say that because I've got the same problem & the program was written using WPF from scratch. – Tony Vitabile Sep 24 '13 at 20:57

1 Answers1

0

It's funny you mention 64 bit because I just managed to solve this error by enabling 'Prefer 32 bit'.

Did you ever understand this better? Hmm I know it's been 10 years lol.

enter image description here

See my question for details.

Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689