我的页面上有一个 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 但不起作用,有什么我错过的吗