xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.87k stars 871 forks source link

avalondock invalid window handle #1013

Open xceedsoftware opened 7 years ago

xceedsoftware commented 7 years ago

luldek[CodePlex]
Hi, my tester is getting such an exception after having the app longer time in background:

System.ComponentModel.Win32Exception

Message: Neplatný popisovač okna ------gt it means quotinvalid window handlequot

Stack Trace: at MS.Win32.UnsafeNativeMethods.GetParent(HandleRef hWnd) at System.Windows.Interop.HwndHost.CalculateAssignedRC(PresentationSource source) at System.Windows.Interop.HwndHost.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Booleanamp handled) at Xceed.Wpf.AvalonDock.Controls.LayoutAutoHideWindowControl.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Booleanamp handled) at System.Windows.Interop.HwndHost.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Booleanamp handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

NativeErrorCode: 1400

ErrorCode: -2147467259

TargetSite: IntPtr GetParent(System.Runtime.InteropServices.HandleRef)

Source: WindowsBase

HResult: -2147467259

it is perhaps corrected in the 2.9.0 plus edition. is there some solution for the community edition?

Thanks, Ludek.

xceedsoftware commented 7 years ago

Boumbles[CodePlex]
In particular. We get this if the application is running and the user accesses the machine it's running on via remote desktop. This only occurs if the machine is on Windows 10, OR Windows 7 and has some sort of desktop management software installed (eg: DisplayFusion).

xceedsoftware commented 7 years ago

Boumbles[CodePlex]
We are still getting this in v2.9.0. I've added a catch for Win32Exception in the override of WndProc in LayoutAutoHideWindowControl to avoid crashes but I don't feel this is an optimal solution

xceedsoftware commented 7 years ago

BoucherS[CodePlex]
Hi,

I suggest you wait for v2.9 and try it again. v2.9 OpenSource should be released shortly.

xceedsoftware commented 7 years ago

lalle1[CodePlex]
We get the same problem with version 2.8 on windows 2012

peteryang023 commented 3 years ago

What's the status of this?

XceedBoucherS commented 3 years ago

Hi, Can you give the repro steps to reproduce this ? Also, what is your code ? We would like to test and see if this issue is already fixed or if it needs more attention. Thanks.

peteryang023 commented 3 years ago

hi @XceedBoucherS, sorry for the delay. I figured it out, the reason for the issue I met is: When closing the floating window, it doesn't trigger the close of the LayoutAnchorable object. I fixed this by binding the Closed event on LayoutFloatingWindowControl, and invokes Close of LayoutAnchorable object to release the resource in the closed event handler. The version I use is v2.9

XceedBoucherS commented 3 years ago

Hi peteryang023, v2.9 is a pretty old version. Could you test it in the latest v4.0 version ? Or send a small sample to test your situation? It could already be fixed, but just to make sure. Thank you.