UI Automation throws COMException

Varun Kumar 6 Reputation points
2022-01-20T07:52:49.297+00:00

Documentation for UI Automation does not mention anything about COMException. However, I encountered the below exception:

System.Runtime.InteropServices.COMException
à System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32, IntPtr)
à MS.Internal.Automation.UiaCoreApi.CheckError(Int32)
à MS.Internal.Automation.UiaCoreApi.UiaGetUpdatedCache(MS.Internal.Automation.SafeNodeHandle, UiaCacheRequest, NormalizeState, System.Windows.Automation.Condition)
à System.Windows.Automation.AutomationElement.Normalize(System.Windows.Automation.Condition, System.Windows.Automation.CacheRequest)
à System.Windows.Automation.TreeWalker.Normalize(System.Windows.Automation.AutomationElement)

What are the possible reasons for such exceptions? The documentation for UI Automation does not mention anything about COMExceptions and so it not clear that whether these exception should be handled or not.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,309 questions
{count} vote