Windows Form Hosting WPF Control Bug

Hi, I found a bug with regards to hosting a WPF Control in a Windows Form. When you host a WPF Control on a nonmodal Windows Form dialog and then close this dialog, you receive a NullReferenceException in the Dispose method on the parent Window Form with the source of the exception coming from "WindowsFormsIntegration". I have created a simple sample project if an example is needed.

Here's the stack trace:

" at System.Windows.Forms.Integration.ElementHost.InputManager_PostProcessInput(Object sender, ProcessInputEventArgs e)\r\n at System.Windows.Input.InputManager.ProcessStagingArea()\r\n at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)\r\n at System.Windows.Interop.HwndMouseInputProvider.PossiblyDeactivate(IntPtr hwndCapture, Boolean stillActiveIfOverSelf)\r\n at System.Windows.Interop.HwndMouseInputProvider.Dispose()\r\n at System.Windows.Interop.HwndSource.Dispose(Boolean disposing)\r\n at System.Windows.Interop.HwndSource.OnHwndDisposed(Object sender, EventArgs args)\r\n at MS.Win32.HwndWrapper.Dispose(Boolean disposing)\r\n at MS.Win32.HwndWrapper.Dispose()\r\n at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)\r\n at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)\r\n at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)\r\n at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n at System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)\r\n at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)\r\n at System.Windows.Forms.NativeWindow.DestroyHandle()\r\n at System.Windows.Forms.Control.DestroyHandle()\r\n at System.Windows.Forms.Control.Dispose(Boolean disposing)\r\n at System.Windows.Forms.Form.Dispose(Boolean disposing)\r\n at WFHost.Form1.Dispose(Boolean disposing) in C:\\Documents and Settings\\kcheuk\\Desktop\\WindowsFormsHostingAvalonControl2\\CSharp\\WFHost\\Form1.Designer.cs:line 19\r\n at System.ComponentModel.Component.Dispose()\r\n at System.Windows.Forms.ApplicationContext.Dispose(Boolean disposing)\r\n at System.Windows.Forms.Application.ThreadContext.DisposeThreadWindows()"



Answer this question

Windows Form Hosting WPF Control Bug

  • PaulDrda

    Can I see your example b/c I've never seen a such bug with my code...

    Thanks



  • Windows Form Hosting WPF Control Bug