I'm writing a C# program that makes use of the webBrowser control. Generally I've been successful in using it but have encountered a problem I can't figure out.

I intercept the DocumentCompleted event from my webBrowser control. During the processing of that event I create an additional webBrowser control and call its Navigate function to tell it to navigate to a specific URL. When I do that it throws an exception : "IWebBrowser2 get from the native ActiveX control did not succeed", and I can see that the axIWebBrowser2 property of the control is null.

My code is approximately like this:

private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
   webBrowser newWebBrowser = new webBrowser(); 
     MessageBox.Show("Excption was thrown!");

Is it possible that you can't instantiate and call the Navigate method for a webBrowser while processing the DocumentCompleted event for another webBrowser control?

Why are you calling the original web browser if you're creating a new one called newWebBrowser?

That's just a typo. It should say,


The code I presented is just a summary. The key issue is that it's failing to do the Navigate only under the situation where the Navigate is called (on a different webBrowser control) from within the DocumentCompleted event handler of a webBrowser control. What is it about being inside the event handler when trying to invoke a Navigate function on some other webBrowser that causes it to fail?