小编Sar*_*uru的帖子

webbrowser.document 抛出指定的强制转换无效异常

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

winforms c#-4.0

1
推荐指数
1
解决办法
3765
查看次数

标签 统计

c#-4.0 ×1

winforms ×1