Menu

specified cast is not valid

Alex Frost
2025-05-13
2025-06-29
  • Alex Frost

    Alex Frost - 2025-05-13

    Sometimes, when I use the KeePass auto type, I get this error screen and KeePass blocks until I close the error window:
    specified cast is not valid

    I am now runnig KeePass with the debug option and got some more information. It looks like it has to to with this plugin. I just upgraded from version 6.9.0.0 to 6.9.1.0, so maybe the problem is solved now. I did not find any tickets regarding this subject, so I will post the error info here anyway:


    KeePass

    Specified cast is not valid.
    InvalidCastException (0x80004002) @ System.Object get_accRole(System.Object)
    at Accessibility.IAccessible.get_accRole(Object varChild)
    at WebAutoType.AccessibleObjectHelper.AccessibleObjectMatchesConditions(IAccessible accessibleObject, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState) at WebAutoType.AccessibleObjectHelper.FindChild(IAccessible parent, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState)
    at WebAutoType.ChromeBrowserUrlReader.TryGetAccessibleDocFromRenderWindow(IntPtr chromeRenderHwnd)
    at WebAutoType.ChromeBrowserUrlReader.GetDocument()
    at WebAutoType.BrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
    at WebAutoType.ChromeBrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
    at WebAutoType.WebAutoTypeExt.AutoType_SequenceQueriesBegin(Object sender, SequenceQueriesEventArgs e)
    at KeePass.Util.AutoType.GetSequencesForWindowBegin(IntPtr hWnd, String strWindow)
    at KeePass.Util.AutoType.PerformGlobal(List`1 lSources, ImageList ilIcons, String strSeq)
    at KeePass.Forms.MainForm.ExecuteGlobalAutoType(String strSeq)
    Accessibility


    OK

    Is this indeed a bug in WebAutoType?

     

    Last edit: Alex Frost 2025-05-13
  • AlexVallat

    AlexVallat - 2025-05-13

    This is certainly coming from WebAutoType, but I don't know whether it's a bug or not. Does it only happen with a specific website? Are there steps you can take which make it happen reliably?

    From the stack trace you've supplied it does not look like something WebAutoType can fix, as it's happening internally within the Windows accessibility code, but it should at least be possible to trap it and not crash when it happens, instead just failing to auto-type.

     
  • Alex Frost

    Alex Frost - 2025-05-16

    This seems to happen randomly on various sites, hard to reproduce 😔. When it happens and I close the error window, I can just pres CTRL+ALT+A on my keyboard again for that same site and it just works fine.

     
  • AlexVallat

    AlexVallat - 2025-05-17

    OK, thanks for letting me know. If it doesn't actually cause KeePass to crash out or stop working then it's not so serious, but still irritating.

    Is it Chrome that you are using, or one of the other Chrome-based browsers?

     
  • Alex Frost

    Alex Frost - 2025-05-18

    My default browser is Edge, but I do use Chrome (and even some other browsers). Next time, I will pay attention which browser is concerns as it indeed might be browser specific.

     
  • Alex Frost

    Alex Frost - 2025-05-26

    Just had the issue this morning... With Chrome...
    Will let you know as soon as (and if) I experience the issue with Edge too.

     
  • AlexVallat

    AlexVallat - 2025-05-26

    Thanks for reporting back. I have created a possible workaround fix, as you say that if you just try again on the same site then it works. With the attached, WebAutoType will detect the error and automatically retry once to see if it is just an intermittent fault. If it still fails, the error will be reported normally.

    If you try this, and still see the error, then the only other option may be to have it simply ignore it, but having it silently fail to find the window is not necessarily an improvement on reporting the error anyway.

     
  • Alex Frost

    Alex Frost - 2025-06-10

    Hi, I have the update installed, but the auto retry does not seem to work. I get a sound notification when I tried the autotype in Chrome, but still had to go to KeePass and click 'OK' in the message window 😁

     

    Last edit: Alex Frost 2025-06-10
  • Alex Frost

    Alex Frost - 2025-06-25

    I just got the error with Edge! So ti happens both wih Edge as with Chrome (but of course, Edge runs on Chromium). The auto retry fix does nor work, because you explicitly click the 'OK' button in the error Window. I guess it is more of the same, but here is the error window message


    KeePass

    Specified cast is not valid.
    InvalidCastException (0x80004002) @ System.Object get_accRole(System.Object)
    at Accessibility.IAccessible.get_accRole(Object varChild)
    at WebAutoType.AccessibleObjectHelper.AccessibleObjectMatchesConditions(IAccessible accessibleObject, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState) at WebAutoType.AccessibleObjectHelper.FindChild(IAccessible parent, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState)
    at WebAutoType.ChromeBrowserUrlReader.TryGetAccessibleDocFromRenderWindow(IntPtr chromeRenderHwnd)
    at WebAutoType.ChromeBrowserUrlReader.GetDocument()
    at WebAutoType.BrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
    at WebAutoType.ChromeBrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
    at WebAutoType.WebAutoTypeExt.AutoType_SequenceQueriesBegin(Object sender, SequenceQueriesEventArgs e)
    at KeePass.Util.AutoType.GetSequencesForWindowBegin(IntPtr hWnd, String strWindow)
    at KeePass.Util.AutoType.PerformGlobal(List`1 lSources, ImageList ilIcons, String strSeq)
    at KeePass.Forms.MainForm.ExecuteGlobalAutoType(String strSeq)
    Accessibility


    OK

     
  • AlexVallat

    AlexVallat - 2025-06-29

    Thanks for reporting back. That's a shame that automatic retrying isn't going to help then. This might be something that has to be fixed on Chrome, unfortunately.

     
  • Alex Frost

    Alex Frost - 2025-06-29

    Hi. what do you mean with 'something that has to be fixed on Chrome'? That is why I reported that I had the issue with Edge this time 😁
    I use Firefox, Brave and Ghostery too, but not that often. As soon as I encounter the problems on one of those, I will report it too.

    Thanks.

     
    • AlexVallat

      AlexVallat - 2025-06-29

      I mean that Chrome (well, Chromium) will have to fix it on their side, so that the accessibility request no longer throws that error. It did not use to, hopefully they will fix it in the future. Edge is just another Chrome variant so if Chrome fixes it the fix will end up in Edge too.

      Firefox is not a Chrome variant, so is not affected. Brave is another Chrome.

       
  • Alex Frost

    Alex Frost - 2025-06-29

    Yeah, both Chromium. Realized that after I posted. All clear 😁

     

    Last edit: Alex Frost 2025-06-29

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.