The exception indicates that either WebBrowser1 or WebBrowser1.ActiveXInstance is null...I'm not sure which one, though. If you put a breakpoint on that line and debug, you can use the immediate window to run the following 2 commands:
Code:
?WebBrowser1
?WebBrowser1.ActiveXInstance
One of those should be null (or Nothing). Alternatively, I suppose you could just add an assert:
Code:
Public Sub New()
InitializeComponent()
' Cast to WebBrowser, so that we can subscribe to the NewWindow3 event
Debug.Assert(WebBrowser1 IsNot Nothing)
Debug.Assert(WebBrowser1.ActiveXInstance IsNot Nothing)
AddHandler DirectCast(WebBrowser1.ActiveXInstance, SHDocVw.WebBrowser).NewWindow3, AddressOf WebBrowser1_NewWindow3
End Sub
What I meant by default URL is to set the Url property of WebBrowser1 to something in the Designer's PropertyPane. That'll give it a Url in the InitializeComponent() method, which is how I did it.