2

What is wrong with this:

webBrowser1.Url = new System.Uri("http://www.google.com");
MessageBox.Show(webBrowser1.Url.ToString());

When the message box tries to run it complains of a null exception.

I think I may have found the solution to my problem, it seems that I was trying to read the value before it was initalized, once I had checked this it worked perfectly. Noob error. :o(

4

1 回答 1

2

Did you perhaps not initialize webBrowser1?

var webBrowser1 = new WebBrowser();
webBrowser1.Url = new System.Uri("http://www.google.com");
MessageBox.Show(webBrowser1.Url.ToString());
于 2012-10-31T13:33:46.250 回答