我的页面上有一个 WebBrowser 控件。在浏览器控件中显示的页面上触发一些 javascript。当我尝试保存我的网页时出现此错误
String strHtml = _browser.Document.Body.OuterText;
File.WriteAllText("C:\saveme.html", strHtml);
Run Code Online (Sandbox Code Playgroud)
而这一行 _browser.Document.Body.OuterText 抛出异常
Exception:: Specified cast is not valid.
at System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation()
at System.Windows.Forms.WebBrowser.get_Document()....
Run Code Online (Sandbox Code Playgroud)
我也用过 Invoke 但没有用,有什么我错过的吗