E_FAIL exceptions on Invoke - debugging from source

Jan 17, 2013 at 6:56 PM

I am attempting to convert a small UI automation tool, which had been built using the .NET Framework System.Windows.Automation, to this adapter.

It did successfully "drop-in replace" the existing API, and am pleased that this wrapper to the newer 3.0 unmanaged UIA API is significantly faster (on my Windows 7 SP1, x64, Enterprise system)

Unfortunately,  I am getting numerous runtime exceptions when I attempt to run the tests, so I've downloaded the source, and the Inspect.exe Win7 SDK utility to compile/review the app and dig deeper (I understand that some of the element name/id handling has changed)

My first concern: In UIComWrapper.sln - the LocalTestRun tests only pass 58/65 (tried building both AnyCPU and as x86) - 7 tests failed as follows:

  1. TablePatternCachedTest - Class Initialization method UIAComWrapperTests.ExplorerTargetTests.MyClassInitialize threw exception.  System.InvalidOperationException: System.InvalidOperationException: Operation is not valid due to the current state of the object..
  2. TestImageMismatch - Assert.AreNotEqual failed. Expected any value except: <TestButton>. Actual <TestButton>.
  3. TablePatternTest - (same error as #1)
  4. MultipleViewPatternTest - (same as #1)
  5. TreeIterationTest (same as #1)
  6. MultipleViewerPatternCachedTest (same as #1)
  7. GridPatternTest (same as #1)

Is this expected?  Are there any caveats about using this on a Win7 x64?

Secondly, the first COM (E_FAIL) is occuring on an Invoke of a menu entry.  The invocation succeeds (the appropriate dialog appears), but the COM layer is returning a generic error.

 Exception  -  System.Runtime.InteropServices.COMException - Error HRESULT E_FAIL has been returned from a call to a COM component.  Data: Microsoft.Scripting.Interpreter.InterpretedFrameInfo -> Microsoft.Scripting.Interpreter.InterpretedFrameInfo[]  Data: Microsoft.Scripting.Runtime.DynamicStackFrame -> System.Collections.Generic.List`1[Microsoft.Scripting.Runtime.DynamicStackFrame]   at UIAutomationClient.IUIAutomationInvokePattern.Invoke()   at System.Windows.Automation.InvokePattern.Invoke() in C:\Users\Michael\Desktop\Global\CodePlex\UIAComWrapper\UIAComWrapper\InvokePattern.cs:line 35

I am started a debug session on this issue next.  As I'm new to the automation API, any guidance would be appreciated.

Oct 18, 2013 at 12:36 AM
Wow... It's been a long time and no one has responded. I'm having the same issues today and need some answers...