Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Bug report: Closing a Window with a WindowsFormsHost causes excep

 
 
Old 02-24-2006   #1 (permalink)
Chris Sammis


 
 

Bug report: Closing a Window with a WindowsFormsHost causes excep

This behavior is observed with the February CTP:

DESCRIPTION:
I have a Window with a WindowsFormsHost on it that is hosting a
System.Windows.Forms.TextBox. Closing the window via an invokation causes an
System.ComponentModel.Win32Exception: "Invalid Window Handle." Closing the
window directly (using the Close button on the title bar) does not trigger
the exception.

STACK TRACE:
at System.Windows.Interop.HwndHost.BuildOrReparentWindow()
at System.Windows.Interop.HwndHost.OnSourceChanged(Object sender,
SourceChangedEventArgs e)
at System.Windows.SourceChangedEventArgs.InvokeEventHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object
target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target,
RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
at
System.Windows.PresentationSource.UpdateSourceOfElement(DependencyObject
doTarget, DependencyObject doAncestor, DependencyObject doOldParent)
at System.Windows.PresentationSource.RootChanged(Visual oldRoot, Visual
newRoot)
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Window.SourceWindowHelper.ClearRootVisual()
at System.Windows.Window.ClearRootVisual()
at System.Windows.Window.CloseWindowFromWmClose()
at System.Windows.Window.WmClose()
at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg,
IntPtr wParam, IntPtr lParam, Boolean& handled)
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, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,
Delegate callback, Object args, Boolean isSingleParameter, Delegate
catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Boolean
isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority
priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.UnsafeSendMessage(IntPtr hWnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
at System.Windows.Window.InternalClose(Boolean shutdown, Boolean
ignoreCancel)
at System.Windows.Window.Close()
at
LoginScreen.LoginScreen.<>c__DisplayClass7.<ProtocolConnectionComplete>b__6()
in C:\bs_svn\shaim\src\plugins\ui\LoginScreen\LoginScreen.xaml.cs:line 304


WORKAROUND:
Calling Dispose() on the WindowsFormsHost prior to calling Close() on the
window appears to work around the problem.

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
closing a window when done .NET General
CMD window now closing Vista General
Failed at closing a window with more than 1 tab. Vista General
Closing window Vista General
Re: Problem when closing IE 7--pops up dialog to send error report Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46