在解析网页时,以下函数在我本地运行时可以正常工作:
Public Function GetElement(ByVal IHTMLDOMNode As mshtml.IHTMLDOMNode, ByVal InnerText As String) As mshtml.IHTMLElement
Dim objIHTMLAnchorElement As mshtml.HTMLAnchorElementClass
Dim s As String
s = Microsoft.VisualBasic.Information.TypeName(IHTMLDOMNode)
If s = "HTMLAnchorElementClass" Then
t = GetType(mshtml.HTMLAnchorElementClass)
objIHTMLAnchorElement = Marshal.CreateWrapperOfType(IHTMLDOMNode, t)
If objIHTMLAnchorElement.innerText.Trim() = InnerText Then
Return objIHTMLAnchorElement
End If
End if
' code that loks at child nodes and makes a recursive call
但是,当它部署在 Web 主机提供商处时,相同的输入会导致字符串 s 是“HTMLAnchorElement”而不是“HTMLAnchorElementClass”。
如果我将代码更改为
Dim objIHTMLAnchorElement As mshtml.HTMLAnchorElement
Dim s As String
s = Microsoft.VisualBasic.Information.TypeName(IHTMLDOMNode)
If s = "HTMLAnchorElement" Then
t = GetType(mshtml.HTMLAnchorElement)
objIHTMLAnchorElement = Marshal.CreateWrapperOfType(IHTMLDOMNode, t)
If objIHTMLAnchorElement.innerText.Trim() = InnerText Then
Return objIHTMLAnchorElement
End If
End if
我收到“类型必须是 __ComObject 或派生自 __ComObject”错误
这种行为的原因可能是什么和/或我能做些什么?