locked
NonComVisibleBaseClass was detected

    General discussion

  • When using the UI Automation API, I get this error:

    NonComVisibleBaseClass was detected:

    "A QueryInterface call was made requesting the class interface of COM visible managed class 'MS.Internal.AutomationProxies.WindowsEditBox'. However since this class derives from non COM visible class 'MS.Internal.AutomationProxies.ProxyHwnd', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules."

    When it finds a button, currently hidden on the target application (myProcess).

    Here is the code:
    Imports System.Windows.Automation
    Dim aeDesktop As AutomationElement = AutomationElement.RootElement
    Dim aeForm As AutomationElement = aeDesktop.FindFirst(TreeScope.Children, New PropertyCondition(AutomationElement.ProcessIdProperty, myProcess.Id))
    Dim actionButton As AutomationElement = aeForm.FindFirst(TreeScope.Descendants, New PropertyCondition(AutomationElement.NameProperty, "String"))

    I tried try catch, and on error resume next, but it didn't seem to work.

    I am grateful for answers!
    • Edited by FraVats Thursday, May 07, 2009 4:11 PM
    • Changed type Riquel_DongModerator Thursday, May 14, 2009 10:04 AM redirect to Windows Presentation Foundation forum
    Thursday, May 07, 2009 4:08 PM

All replies

  • System.Windows.Automation Namespace provides support for Windows Presentation Foundation (WPF) UI Automation clients. Please post WPF issue to WPF forum for better help.

    http://social.msdn.microsoft.com/Forums/en-US/wpf/threads

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 11, 2009 7:30 AM
  • Actuall this diag is not considered as an exception, it only display when you debug the Auto UI program, if you build a release version for your program, it will run normally, at least in my demo it was that.
        class Program
        {
            static void Main(string[] args)
            {
                Process pro = new Process();
                pro.StartInfo = new ProcessStartInfo("Excel.exe");
                pro.Start();
               
                Thread.Sleep(1000);
                AutomationElement excel = GetFirstWindow();// GetWindowElement("Microsoft Excel - Book1");
                excel.SetFocus();
                AutomationElementCollection view = null;
                view = excel.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "View"));
                AutomationElement test = view[0];
                InvokePattern btntest = test.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                btntest.Invoke();

            }
    if you step into this demo, it will give that diag, when you continue step, it will normal.
    Monday, June 01, 2009 7:36 AM
  • You can turn off the managed Debugging Assistant for the "NonComVisibleBaseClass" exception. In Visual Studio,

    1. Navigate to Debug->Exceptions...
    2. Expand "Managed Debugging Assistants"
    3. Uncheck the NonComVisibleBaseClass Thrown option.
    4. Click [Ok]

    Wednesday, October 28, 2009 11:37 AM
  • Thanks svb70, it worked for me, thanks :)
    • Edited by ikon soft Thursday, October 04, 2012 9:37 AM
    Thursday, October 04, 2012 9:36 AM
  • Hi svb70,

    I am using Visual C# express edition 2010. I am unable to find these steps on it,

    1. Navigate to Debug->Exceptions...
    2. Expand "Managed Debugging Assistants"
    3. Uncheck the NonComVisibleBaseClass Thrown option.

    Do you have any idea how to tackle this issue on express edition?

    Many Thanks,
    Shashikant

    Monday, October 08, 2012 6:53 AM
  • If you are not able to see the exception you can add it.

     Tools->Customize->Commands->select Debug->Click Add command->Select Debug->on right hand pane Exceptions click OK

    Tuesday, October 09, 2012 1:27 AM
  • Many Thanks Slackerpin :)
    Tuesday, October 09, 2012 4:24 AM