【发布时间】:2012-09-15 14:40:51
【问题描述】:
我的页面上有一个 WebBrowser 控件。在浏览器控件中显示的页面上触发一些 javascript。当我尝试保存我的网页时出现此错误
String strHtml = _browser.Document.Body.OuterText;
File.WriteAllText("C:\saveme.html", strHtml);
而 _browser.Document.Body.OuterText 这一行会抛出异常
Exception:: Specified cast is not valid.
at System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation()
at System.Windows.Forms.WebBrowser.get_Document()....
我也使用过 Invoke 但不起作用, 有什么我错过的吗
【问题讨论】: