picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.52k stars 319 forks source link

Work around bug in WPF when running in .NET Core #2618

Closed cwensley closed 4 months ago

cwensley commented 4 months ago

WPF can cause crashes with the following stack trace, seemingly in random places:

System.ComponentModel.Win32Exception (87): The parameter is incorrect.
   at MS.Win32.UnsafeNativeMethods.GetWindowText(HandleRef hWnd, StringBuilder lpString, Int32 nMaxCount)
   at System.Windows.Automation.Peers.WindowAutomationPeer.GetNameCore()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
   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)

It has been fixed in the WPF repo, see https://github.com/dotnet/wpf/issues/4181 and https://github.com/dotnet/wpf/pull/7345, but hasn't been merged into a release yet so we override the automation peer and catch the exception there.