Trying to resolve getting IP from host name but I get this warning on RetIP: (on Return RetIP line) "Variable 'RetIP' is used before it has been assigned a value. A null reference exception could result at runtime."
Public Function GetIPFromHostname(ByRef Host As String) As System.Net.IPAddress()
Dim IP As System.Net.IPHostEntry
'Dim host As System.Net.IPHostEntry
Dim RetIP As System.Net.IPAddress()
Try
'Host = System.Net.Dns.GetHostByAddress(IP)
IP = System.Net.Dns.GetHostEntry(Host)
RetIP = IP.AddressList()
Catch ex As Exception
Console.WriteLine("Cannot resolve IP address from hostname ({0}) - {1}", Host, ex.Message)
End Try
Return RetIP
End Function
This code used to work in VB 2008 and 2010 but now doesn't work. Any idea what I'm missing here?