any one know of a tutorial for using the System.Windows.Forms.WebBrowser object? Had a look around but can't find one. The code I have so far is (the very complex):
System.Windows.Forms.WebBrowser b = new System.Windows.Forms.WebBrowser();
b.Navigate("http://www.google.co.uk");
but it doesn't actually navigate anywhere (i.e. b.Url is null, b.Document is null etc)
Thanks
It takes time for the browser to navigate to a page. The Navigate() method does not block until the navigation is complete, that would freeze the user interface. The DocumentCompleted event is fired when it's done. You have to move your code into an event handler for that event.
An additional requirement is that the thread on which you create a WB is a happy home for single-threaded COM components. It must be STA and pump a message loop. A console mode app does not meet this requirement, only a Winforms or WPF project has such a thread. Check this answer for a solution that's compatible with console mode programs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With