tags:

views:

9

answers:

0

Using .Net Reflector on System.Runtime.Remoting.Channels.CoreChannel I decompiled the 2 methods below. GetMachineIp() is called when setting up an HttpChannel for remoting.

internal static string GetMachineIp()
{
    if (s_MachineIp == null)
    {
        IPHostEntry hostEntry = Dns.GetHostEntry(GetMachineName());
        AddressFamily addressFamily = Socket.SupportsIPv4 ? 
            AddressFamily.InterNetwork : AddressFamily.InterNetworkV6;
        IPAddress machineAddress = GetMachineAddress(hostEntry, addressFamily);
        if (machineAddress != null)
        {
           s_MachineIp = machineAddress.ToString();
        }
        if (s_MachineIp == null)
        {
            throw new ArgumentNullException("ip");
        }
}
return s_MachineIp;

}

internal static string GetMachineName()
{
    if (s_MachineName == null)
    {
        string hostName = GetHostName();
        if (hostName != null)
        {
            IPHostEntry hostEntry = Dns.GetHostEntry(hostName);
            if (hostEntry != null)
            {
                s_MachineName = hostEntry.HostName;
            }
        }
        if (s_MachineName == null)
        {
            throw new ArgumentNullException("machine");
        }
    }
    return s_MachineName;

}

My question is why would Dns.GetHostEntry() in GetMachineIP() fail with SocketException "No such host is known". GetMachineName() returns successfully (which also does a GetHostEntry). This is only happening on an isolated machine. Could it be something to do with incorrect DNS registration?