Click here to Skip to main content
15,915,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

While I am using the below code to get ipaddress of current localhost I am getting some error messages.

My code:
VB
Dim WC As System.Net.WebClient
Dim ipaddress As String = System.Text.Encoding.ASCII.GetString((WC.DownloadData("http://www.whatismyip.com/automation/n09230945.asp";)))


error message:
System.NullReferenceException: Object reference not set to an instance of an object.

Can anyone tell me the solution to solve this prob?
Posted
Updated 8-Dec-10 22:13pm
v2
Comments
Dalek Dave 9-Dec-10 4:13am    
Edited for Grammar and Readability.

1 solution

This is the Solution:
VB
Dim WC As New System.Net.WebClient
Dim ipaddress As String = System.Text.Encoding.ASCII.GetString((WC.DownloadData("http://www.whatismyip.com/automation/n09230945.asp")))
MessageBox.Show(ipaddress)


You missed the New Keyword to declare Object..
 
Share this answer
 
v2
Comments
ramuksasi 9-Dec-10 3:44am    
thanks for ur help rajesh.. its working fine ..
Rajesh Anuhya 9-Dec-10 3:48am    
Welcome :)
Dalek Dave 9-Dec-10 4:14am    
Good Answer! (I fixed a spelling error whilst I was at it).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900