//private static readonly string openDnsResolver2 = "208.67.220.220"; /// <summary> /// Resolves the IP address of the specified hostname. /// </summary> /// <param name="hostname">The hostname.</param> /// <returns>IPAddress instance.</returns> public IPAddress ResolveHostnameIP(string hostname) { if (!NetworkInterface.GetIsNetworkAvailable()) { throw new ApplicationException(Text.Error_NoNetwork); } Resolver resolver = new Resolver(openDnsResolver1); IPHostEntry host = resolver.GetHostEntry(hostname); if (host == null || host.AddressList == null || host.AddressList.Length <= 0) { throw new ApplicationException(string.Format(Text.Error_CantResolveHostnameIP, hostname)); } IPAddress result = host .AddressList .FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork); if (result == null) { throw new ApplicationException(string.Format(Text.Error_CantResolveHostnameIP, hostname)); } log.DebugFormat(Text.Debug_ResolvedHostname, hostname, result.ToString()); return result; }