原先的代码为:

IHTMLDocument2 doc = (IHTMLDocument2)webBrowser.Document;

 

但是运行时会提示:无法将类型“System.Windows.Forms.HtmlDocument”转换为“mshtml.IHTMLDocument2”

 

将代码修改为:IHTMLDocument2 doc = (IHTMLDocument2)webBrowser.Document.DomDocument;

 

这样就可以正常使用了.

相关文章:

  • 2021-09-13
  • 2021-07-30
  • 2021-10-05
  • 2021-05-03
  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2021-10-21
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案