Exception with Windows 7

May 6, 2010 at 2:39 AM


I kept receiving a SocketException everytime I ran code through the DnDns regardless of if I passed in a DNS server or not (letting DnDns find a DNS server itself).  I am running VS2008 on Windows 7.  I traced down the issue and found that it was in DnsQueryRequest.cs Line 196.  Apparently the Win7 security module (maybe Vista too?) prohibits access to the System.Net.Dns.GetHostEntry() method by throwing an exception.  I changed the code as follows (original code is commented out):

   IPAddress[] addresses = System.Net.Dns.GetHostAddresses(dnsServer);
   IPAddress ipa = addresses[0];
//   IPHostEntry ipe = System.Net.Dns.GetHostEntry(dnsServer);
//   IPAddress ipa = ipe.AddressList[0]; 

The GetHostAddress() works fine and, in this case, retrieves exactly what we need....the IP address.