无法将“System.__ComObject"类型的 COM 对象转换为接口类型“mshtml.HTMLElementCollection" [英] Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLElementCollection

查看:41
本文介绍了无法将“System.__ComObject"类型的 COM 对象转换为接口类型“mshtml.HTMLElementCollection"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 mshtml 通过 webbrowser 控件在 vb.net 上填写表单,

Am trying to use mshtml to fill a form on vb.net through the webbrowser control,

Dim doc As MSH.IHTMLDocument2 = DirectCast(wbMain.Document.DomDocument, MSH.IHTMLDocument2)
Dim buttons As MSH.HTMLElementCollection = doc.getElementsByTagName("button")
Dim Inputs As MSH.HTMLElementCollection = doc.getElementsByTagName("input")

但我收到以下错误

无法将类型为System.__ComObject"的 COM 对象转换为接口输入mshtml.HTMLElementCollection".此操作失败,因为QueryInterface 调用具有 IID 的接口的 COM 组件{3050F56B-98B5-11CF-BB82-00AA00BDCE0B}"由于以下原因失败错误:不支持此类接口(来自 HRESULT 的异常:0x80004002(E_NOINTERFACE)).

Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLElementCollection'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3050F56B-98B5-11CF-BB82-00AA00BDCE0B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

谁能帮我解决可能的解决方案?

can anyone help me out with the possible solution?

推荐答案

将按钮调暗为 MSH.HTMLElementCollection

Dim buttons As MSH.HTMLElementCollection

类型错误.那应该是一个 IHTMLElementCollection .注意前面的 I.MSDN 页面 在这里.

Wrong type. That should be an IHTMLElementCollection instead. Note the leading I. The MSDN page is here.

缺少 I 的类型是 coclass,而不是接口.由脚本客户端在想要创建自己的集合对象时使用.

The type that is missing the I is a coclass, not an interface. Used by scripting clients when they want to create their own collection object.

这篇关于无法将“System.__ComObject"类型的 COM 对象转换为接口类型“mshtml.HTMLElementCollection"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆