System.Net.DNS

Dns.GetHostEntry( ) does not work if is a variable but does if = "some.domain.com"

IPAddress.Parse( ) does not work if is a variable but does if = "some.domain.com"

Why not :(



Answer this question

System.Net.DNS

  • miliu

    That was exactly what I did. I created a simple test project to perform these 2 simple processes. My development machine runs Windows 2003 with both 1.1 and 2.0 frameworks. I have not encountered any other problems. It worked fine in Visual Studio 2003 but I decided to move up to 2005.


  • bobostra

    Works for me. Is the variable valid What error do you get, or should we guess What's your actual code



  • mt69

    I pasted that exact same code into a new project, and after adding an Imports statement for the System.Net namespace, it seems to work fine.

    Does it do the same (exhibit the same error) when pasted into a new project This is usually what I do to narrow it down, and determine the smallest and simplest project to create the error.



  • sstackho

    dim strHost as string = "151.197.0.38"
    dim ipAddr as IPAddress = IPAddress.Parse(strHost)
    Error: An invalid IP address was specified.
    but this works
    dim ipAddr as IPAddress = IPAddress.Parse("151.197.0.38")

    dim strHost as string = "mail.pfracecars.com"
    dim ipHostInfo as IPHostEntry = Dns.GetHostEntry(strHost)
    Error: No such host is known
    but this works
    dim ipHostInfo as IPHostEntry = Dns.GetHostEntry("mail.pfracecars.com")


  • System.Net.DNS