I have a Server Named "MyServer" with an IP Address of ""

I'm having a problem with one particular IP Address. If I use Dns.GetHostEntry("MyServer"), I get the IPHostEntry object. If I use Dns.GetHostEntry(""), I get a SocketException. Finally, if I use the deprecated function Dns.GetHostByName(""), I get the IPHostEntry object.

I only get the error (as far as I can tell) when I use this one particular IP Address. Does anyone have an idea as to what may be going on

Here is my code:

Example 1:

strHostName = "MyServer";

IPHostEntry iph = Dns.GetHostEntry(strHostName); // Works

Example 2:

strHostName = "";

IPHostEntry iph = Dns.GetHostEntry(strHostName); // Throws a SocketException {"No such host is known"}

Example 3:

strHostName = "";

IPHostEntry iph = Dns.GetHostByName(strHostName); // Works

Re: .NET Framework Networking and Communication Dns.GetHostEntry problem

Mariya Atanasova - MSFT

Most probably your DNS server doesn't have an entry for this particular IP address. Try "nslookup" from the console and see what result are you getting.

You have to either register this machine with your dns servers or put the entry in your hosts file. Then GetHostEntry will be able to resolve.

I am guessing GetHostByName() will return the same IP address as the name if it fails to resolve.


Re: .NET Framework Networking and Communication Dns.GetHostEntry problem


Thanks, I think that is it. nslookup returns with a different name than what I am expecting.

nslookup MyServer returns with the correct name.

I'll have to get with my nework admin guys to get it straightened out.