_Kris

In a small console application I used DNS.resolve to obtain either the IP-address(es) or hostname depending on the parameter passed (computername or IP address).

I've rewrited the little thing in Visual Studio 2005 and so I saw that I needed to use dns.GetHostEntry instead of dns.resolve because the last method has become obsolete. So I did.

But when executing the code the behavior is somewhat different: dns.gethostentry doesn't retrieve the hostname if you pass an IP address, were dns.resolve has no problem in showing me the hostname found.

Is this a known issue Is there a workarround or solution



Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Vadmyst

Did you check the value of IPHostEntry.HostName

Can you put the code, where you do dns query





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Mike Flasko

As noted above, the following is probably your answer:

IPHostEntry e = Dns.GetHostEntry(IPAddress.Parse("x.x.x.x"));

Console.WriteLine(e.HostName);






Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

gman1

I want to thank Microsoft for ruining a perfectly operable code such as Dns.Resolve(stringIp).

I tried the above code, although it does work, It's not the aggessive code that .Resove was.

Is there still any imaginable way to use Dns.Resolve. It still appears in the Intellisence dropdown menu, so it must apply somewhere.





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Durgaprasad Gorti

Before you thank us profoundly, could you please tell us
what it is that you are missing in Resolve that is not there in
GetIPHostEntry




Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Jack3r

Hi,

I have same kind of problem. Actually my development station have 2 networks cards, on two subnets (10.10.0.1 & 10.162.130.1). I want to convert my code to use the newer GetHostEntry, but if I try by using the IP address, GetHostEntry can't found my machine name. For test purpose I try this code:

Dim test1, test2, test3, test4, test5 As String
test1 = Dns.Resolve("10.10.0.1").HostName
test2 = Dns.GetHostEntry("10.10.0.1").HostName
test3 = Dns.Resolve("10.162.130.1").HostName
test4 = Dns.GetHostEntry("10.162.130.1").HostName
test5 = Dns.GetHostEntry(IPAddress.Parse("10.162.130.1")).HostName

The station is alone on the 10.10.0.1 network, and the DNS Server is on the other network. The first two tests, return my own address (10.10.0.1), it seam good because the DNS don't any reference to this address. The problem come when I try with the other address. The Resolve return my station longname , but the two last GetHostEntry report an error, like "Unknow Host".

Is anything wrong with this method to get the host name

Thank
Jacques





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Durgaprasad Gorti

The issue is the reverse lookup. Traditionally DNS Servers are supposed to resolve the names to addresses. The reverse of that - looking up a host name based on IPAddress is not reliable and in Ipv6 it is not supported. So my recommendation is to not to write apps that rely on reverse lookup.

I will look into why exactly the difference exists in GetHostEntry and Resolve.






Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Jim Andre Andersen

Did anyone find the reason to why .GetHostEntry doesn't work as good as .Resolve does

What is the technical difference between .GetHostEntry and .Resolve anyway Is there any way to work around this problem

Thanks.





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

PAULL

I am having an issue with this. The problem is easily demonstrated in the debug window:

This returns a computer name:

System.Net.Dns.GetHostByAddress("192.168.1.9").HostName.ToString

This returns a computer name:

System.Net.Dns.Resolve("192.168.1.9").HostName.ToString

But this returns an IP address

System.Net.Dns.GetHostEntry("192.168.1.9").HostName

But the compiler doesnt let you use Resolve or GetHostByAddress any more. Would appreciate any feedback on how to get the hostname without using the debug window

thanks





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

PAULL

BTW the workaround is to turn "treat all warnings as errors" off in project properties, and then the compiler lets you use the old functions, but thats absolute rubbish of course for anyone who want to write good code!



Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

ScottRogersGBR

Agreed, using obsolete code is bad practice and there appears to not be any other option for the mean time. I don't understand why microsoft would release updated code with reduced functionality i.e. the removal of the reverse lookup function

How frustrating.





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

PAULL

I sent an email to Durgaprasad Gorti above (apparently M$) but no response.



Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

Brak59

I am having the same issues as you except that it throws an error for me.

We could really use a response MS

I am going back to Resolve for the time being.





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

pdhot

Does the IP address you are trying to resolve have a PTR record in your DNS Server If not, I don't think it will do a reverse lookup

To find out perform the following from the command line (Assumes the IP address you are trying to lookup is 192.168.1.1).

nslookup

set type=ptr

1.1.168.1.in-addr.arpa

I'll bet you don't get a hostname back. BTW, notice that the 3rd line is the ip address with it's octets reversed and the .in-addr.arpa attached.

I'm not totally sure, but I think that .Resolve may have used a NetBios query if the DNS reverse lookup failed..





Re: .NET Framework Networking and Communication DNS.GetHostEntry doesn't display the hostname as dns.resolve did

gel

I am having the same problem with GetHostEntry, it's broken. I am forced to use Resolve, which is marked obsolete. I can't believe you're not going to fix it for XP.

Feedback: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=97815