473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

problems with URL value in webbrowser app

I'm creating a VB 2005 Express app that hosts the webbrowser control. Everything works well except one area: the Navigating event.

In that event, I need to evaluate the URL property of the webbrowser object. The URL is set beforehand in the browser object. I'm using Webbrowser1.URL.ToString to check it. However, I get the following error when I try this:

"A first chance exception of type 'System.NullReferenceException' occurred in (my program name)"

I created a test conditional to evaluate the URL property, as so:

If IsDBNull(Webbrowser1.Url) Then
MsgBox("null url")
Else
MsgBox("not null url")
End If
The result is that the URL is not null-- yet I get the error message above anyway!

Any clues on how to handle this?

Thanks,

Randall Arnold

Mar 2 '06 #1
2 5804
"Randall Arnold" <ra*******************@nokia.com.> schrieb
I'm creating a VB 2005 Express app that hosts the webbrowser
control. Everything works well except one area: the Navigating
event.

In that event, I need to evaluate the URL property of the webbrowser
object. The URL is set beforehand in the browser object. I'm using
Webbrowser1.URL.ToString to check it. However, I get the following
error when I try this:

"A first chance exception of type 'System.NullReferenceException'
occurred in (my program name)"

I created a test conditional to evaluate the URL property, as so:

If IsDBNull(Webbrowser1.Url) Then
MsgBox("null url")
Else
MsgBox("not null url")
End If
The result is that the URL is not null-- yet I get the error message
above anyway!

Any clues on how to handle this?

Why IsDBNull? The type of System.Windows.Forms.WebBrowser.Url is System.Uri.
It can /never/ be DBNull.Value. DBNull.Value is stored only in a database.

If you would want to know whether a property references an object, check for
Nothing:

If webbrowser1.url is nothing then
If I use

txtUrl.Text = WebBrowser1.Url.ToString

to display the new url, I never get a NullReferenceException. Do you have a
public URL that I can use to repro the problem?
Armin

Mar 2 '06 #2
Ok, forget the Null test, as it turned out to be moot. The problem is in
Webbrowser1.URL.ToString . It won't do any good to post a url, and here's
why: that same bit of code works fine in the DocumentComplete and Navigated
events. It just bombs in the Navigating event-- but I still need to
evaluate it there...

Randall Arnold

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OD**************@TK2MSFTNGP14.phx.gbl...
"Randall Arnold" <ra*******************@nokia.com.> schrieb
I'm creating a VB 2005 Express app that hosts the webbrowser
control. Everything works well except one area: the Navigating
event.

In that event, I need to evaluate the URL property of the webbrowser
object. The URL is set beforehand in the browser object. I'm using
Webbrowser1.URL.ToString to check it. However, I get the following
error when I try this:

"A first chance exception of type 'System.NullReferenceException'
occurred in (my program name)"

I created a test conditional to evaluate the URL property, as so:

If IsDBNull(Webbrowser1.Url) Then
MsgBox("null url")
Else
MsgBox("not null url")
End If
The result is that the URL is not null-- yet I get the error message
above anyway!

Any clues on how to handle this?

Why IsDBNull? The type of System.Windows.Forms.WebBrowser.Url is
System.Uri.
It can /never/ be DBNull.Value. DBNull.Value is stored only in a database.

If you would want to know whether a property references an object, check
for
Nothing:

If webbrowser1.url is nothing then
If I use

txtUrl.Text = WebBrowser1.Url.ToString

to display the new url, I never get a NullReferenceException. Do you have
a
public URL that I can use to repro the problem?
Armin

Mar 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: guy | last post by:
Hi all - And apologies if I'm in the wrong newsgroup. I'm a newbie here and I'd certainly appreciate any pointers to the right forum. To the point... We're running a WebBrowser object...
6
by: Dave Booker | last post by:
It appears that I cannot correctly install the AxWebBrowser in VS2005. I can instantiate an "AxWebBrowser browser" and refer to its members, properties, and methods. I'm having trouble with the...
1
by: FierceMuppet2 | last post by:
I have VS2005 and I dropped WebBrowser control onto a form and navigated to a page without any problem. Now, I want to access the HTML Document of the control. Dim d As...
1
by: L. Chernov | last post by:
Hello, I am trying to work with .Net 2005 WebBrowser object, and put it on a "Windows control library" (embedded in a user control class) and then I am executing it from an ASP.Net webform(with...
2
by: Joe | last post by:
Hi I am able to embed Excel into a WebBrowser on my Dev machine but on a client machine an instance of Excel starts in it's own window outside of my form. I have used the WebBrowser with VS 2005...
1
by: jmalone | last post by:
I have a python script that I need to freeze on AIX 5.1 (customer has AIX and does not want to install Python). The python script is pretty simple (the only things it imports are sys and socket)....
5
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I am having problems interacting with flash objects (i.e., Adobe Flash Player 9) in web pages when using a System.Windows.Forms.WebBrowser control. The flash objects always seem to display...
4
by: dennijr | last post by:
sry its long, questions in the last sentance if u wanna jump to it. i just decided that i would include everything that led up to the problem i made a gif video that i wanted to put...
3
by: TedTrippin | last post by:
Hi, Background - I've create a windows application in VS and added a WebBrowser component and all works well. I'm now trying to do this programmatically. My application now listens on a socket...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.