Reputation: 16705
I've been playing with loading a website (specifically my blog) inside a WebBrowser in WPF. My code is pretty much just one line:
WebBrowser.Source = new Uri("http://www.example.net");
When I run this I get scripting error, like this:
I get similar errors when running other web sites, although not always related to Google Ads.
My assumption is that there is an issue with sites that run JS. Is this correct and, if so, why? Is there a way around it?
Upvotes: 0
Views: 463
Reputation: 3533
The problem here is that the WPF WebBrowser did not implement this property as in the 2.0 control. But with reflection you can get to the activexinstance of the webbrowser control to put the browser in silent mode:
dynamic activeX = this.WB.GetType().InvokeMember("ActiveXInstance",
BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
null, this.WB, new object[] { });
activeX.Silent = true;
Upvotes: 1