2010-07-16 12 views
5

Utilizzo di .Net Reflector su System.Runtime.Remoting.Channels.CoreChannel Ho decompilato i due metodi seguenti. GetMachineIp() viene chiamato quando si configura un HttpChannel per i servizi remoti.System.Runtime.Remoting.Channels.CoreChannel.GetMachineIP() da .NET Reflector: spiegare

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; 

}

mia domanda è perché sarebbe Dns.GetHostEntry() in GetMachineIP() esito negativo con SocketException "No Host sconosciuto". GetMachineName() restituisce correttamente (che fa anche un GetHostEntry). Questo sta accadendo solo su una macchina isolata. Potrebbe essere qualcosa a che fare con la registrazione DNS errata?

risposta

1

Scopri i commenti in questa documentazione MSDN:

http://msdn.microsoft.com/en-us/library/ms143998.aspx

Si dice che hai bisogno di un host in avanti/Una voce nel DNS per la macchina. Un'altra voce dice che questo è cambiato nella versione 4.0. Quindi forse puoi provare .NET Framework 4.0 e vedere se risolve il tuo problema. In caso contrario, controllare la registrazione DNS per la macchina.

Spero che questo aiuti!

1

Probabilmente ho riscontrato lo stesso problema: Impostazione di un servizio remoto di .NET HttpChannel non è riuscito con l'eccezione "Nessun host è noto" su una macchina isolata.

Il nome della macchina è risultato essere la causa. GetMachineName ha restituito "12", che quindi è stato interpretato come un indirizzo IP da Dns.GetHostEntry. La modifica del nome del computer ha risolto il problema.

Avrete l'errore per i nomi di computer, che può essere interpretato come gli indirizzi IP da IPAddress.Parse

0

Questo risolto il problema per me:

aggiungere un mapping per il nome del computer a 127.0.0.1 nel file hosts (percorso: "c: \ windows \ system32 \ drivers \ etc \ hosts")

127.0.0.1 <computer name> 
Problemi correlati