VB.NET 2002 code upgraded to 2003

  • Thread starter Thread starter James R. Atherton
  • Start date Start date
J

James R. Atherton

I borrowed some code (Listed below) in VB.NET 2002, and it works great. I
upgraded to 2003 and although this snippet still works, the
(.AddressList(0).Address) portion of it has a squiggly line under it and
states the following:

'Public Property Address() As Long' is obsolete: 'IPAddress.Address is
address family dependant, use Equals method for comparison.'

I would like to fix this, but have no idea how. It's not failing out my
code, but I still want to fix the issue. Any thoughts?

Shared Function GetIPAddress() As String

Dim Address As System.Net.IPAddress

With System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName())

Address = New System.Net.IPAddress(.AddressList(0).Address)

End With

GetIPAddress = Address.ToString

End Function
 
James R. Atherton said:
Address = New
System.Net.IPAddress(.AddressList(0).Address)

Untested:
Address = New System.Net.IPAddress(.AddressList(0).GetAddressBytes)
 
Back
Top