Our application is crashing on some computers because they have some software activating the WPF automation peers. Is there a way to know which application is activating them?
We have a stack trace that shows the following code:
System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) Line 54 + 0x16 bytes C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.CatchException(System.Exception e) Line 2978 Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.CatchExceptionStatic(object source, System.Exception e) Line 2962 + 0x9 bytes Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.CatchException(object source, System.Exception e, System.Delegate catchHandler) Line 177 + 0xd bytes Unknown
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) Line 43 + 0x17 bytes Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 1447 + 0x2d bytes Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 398 Unknown
[Native to Managed Transition]
[Managed to Native Transition]
UIAutomationTypes.dll!System.Windows.Automation.AutomationIdentifier.Register(MS.Internal.Automation.UiaCoreTypesApi.AutomationIdType type, System.Guid guid, string programmaticName) + 0x31 bytes
UIAutomationTypes.dll!System.Windows.Automation.InvokePatternIdentifiers.InvokePatternIdentifiers() + 0x4b bytes
[Native to Managed Transition]
[Managed to Native Transition]
PresentationCore.dll!System.Windows.Automation.Peers.AutomationPeer.Initialize() Line 1840 + 0x28 bytes Unknown
PresentationCore.dll!System.Windows.Automation.Peers.AutomationPeer.AutomationPeer() Line 278 + 0x5 bytes Unknown
[Native to Managed Transition]
[Managed to Native Transition]
PresentationCore.dll!System.Windows.Automation.Peers.AutomationPeer.RaiseFocusChangedEventHelper(System.Windows.IInputElement newFocus) Line 387 Unknown
PresentationCore.dll!System.Windows.Input.KeyboardDevice.ChangeFocus(System.Windows.DependencyObject focus, int timestamp) Line 565 + 0x17 bytes Unknown
PresentationCore.dll!System.Windows.Input.KeyboardDevice.TryChangeFocus(System.Windows.DependencyObject newFocus, System.Windows.Input.IKeyboardInputProvider keyboardInputProvider, bool askOld, bool askNew, bool forceToNullIfFailed) Line 443 + 0xc bytes Unknown
PresentationCore.dll!System.Windows.Input.KeyboardDevice.Focus(System.Windows.DependencyObject focus, bool askOld, bool askNew, bool forceToNullIfFailed) Line 220 + 0x19 bytes Unknown
PresentationCore.dll!System.Windows.Input.KeyboardDevice.Focus(System.Windows.IInputElement element) Line 181 Unknown
PresentationCore.dll!System.Windows.Interop.HwndKeyboardInputProvider.OnSetFocus(System.IntPtr hwnd) Line 558 Unknown
PresentationCore.dll!System.Windows.Interop.HwndKeyboardInputProvider.FilterMessage(System.IntPtr hwnd, MS.Internal.Interop.WindowMessage message, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 379 Unknown
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 1757 + 0x1b bytes Unknown
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 345 + 0x16 bytes Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Line 494 + 0x18 bytes Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 111 + 0xa bytes Unknown
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) Line 41 + 0x17 bytes Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 1447 + 0x2d bytes Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 398 Unknown
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!MS.Win32.HwndSubclass.DefWndProcWrapper(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 672 + 0x29 bytes Unknown
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 424 + 0x1a bytes Unknown
[Native to Managed Transition]
[Managed to Native Transition]
PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox) + 0x120 bytes
PresentationFramework.dll!System.Windows.Window.Show() + 0x5c bytes
PresentationFramework.dll!System.Windows.Window.ShowDialog() + 0x27d bytes
You can see in the middle of the callstack the automation API firing. On most machines this does not happen and the app works fine.
We could address the real issue but given that this happens on a very small set of machines I think it will be faster to stop the application enabling the automation subsystem.