I have this piece of code:
WebBrowser wb = new WebBrowser();
wb.Navigate(URL);
HtmlDocument doc = wb.Document;
I should mention, that I have no WebBrowser Control on a form, it’s just in method in my class.
After this, wb.Document and doc as well are nulls.
Why is that? What do I have to do to obtain this document?
You should handle the DocumentCompleted event and access the document in your event handler when that fires.
Navigation and document loading is handled asynchronously – therefore the control hasn’t actually navigated or loaded anything when the
Navigatemethod returns; hence why these are null.