Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27350

Dns.GetHostByName is Obsolete ???

$
0
0
I'm using a simple function to get the local IP address of the workstation.

Code:

Private Function GetIPAddress() As String
        Dim strHostName As String
        Dim strIPAddress As String
        strHostName = System.Net.Dns.GetHostName()
        strIPAddress = CType(Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList.GetValue(0), IPAddress).ToString
        Return strIPAddress
 End Function

This does not report an error, merely a warning that Dns.GetHostByName is obsoleted, please use GetHostEntry instead. So I substituted as suggested but it does not return the value of the local IP like the obsoleted code does.

Viewing all articles
Browse latest Browse all 27350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>