DispHTMLInputElement cannot read type of element in windows 8/10

183 views Asked by At

In my application I get the element from wpf's webbrowser html through HTMLDocument and set the click listener according to elements type this code works fine in windows 7 but in win 8/10 when i try to check type of element through DispHTMLInputElement,it gets this error:

Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

Code is:

foreach (IHTMLElement el in _doc.body.all)
{
    if (_elementUIdCollection.Contains(((IHTMLUniqueName)el).uniqueID))
        continue;

    //TODO: use properties.json to identify which tags to attach listner to.
    if (el is IHTMLInputElement2 && el is HTMLInputElement)
    {
        if (el.tagName.ToLower() == "input" || el.tagName.ToLower() == "a" || el.tagName.ToLower() == "img")
        {
            DispHTMLInputElement inputElement = el as DispHTMLInputElement;
            if (el.tagName.ToLower() != "input" || (el.tagName.ToLower() == "input" && (inputElement.type == "text" || inputElement.type == "button" || inputElement.type == "radio" || inputElement.type == "checkbox" || inputElement.type == "image")))
            {
                dynamic htmlElement = inputElement;
                EventListener mouseDownListener = new EventListener(htmlElement);
                htmlElement.attachEvent("onmousedown", mouseDownListener);
                mouseDownListener.Event += OnElementMouseDown;

                //To check duplicate Ids in the new elements
                if (_isPasteUsed) CheckDuplicate(el);

                AddElementToCollection(el);
            } 
        }
    }
}
0

There are 0 answers