GetHostEntry on Windows 7 and .NET 3.5

By Perry

This is very useful feature as on Windows 7, it returns IPV4 and IPV6 address combine so you cannot use direct Dns.GetHostEntry(string.Empty).AddressList[0] method to get the IP address of specified machine.

You can simply use below code to get the IP address on specified machine but make sure that you target .NET is set to 3.5 and you have included System.Linq namespace.

IPAddress IP = Dns.GetHostEntry(fqdnHostName).AddressList.FirstOrDefault(addr => addr.AddressFamily.Equals(AddressFamily.InterNetwork));

Related FAQs

This shows how I got rid of authentication prompt while opening Excel or Word files on Windows 7. This was happening when I open Office files placed on my network location from IE8 or Firefox. Putting corresponding sweblink in trusted site doesn't worked.
I wrote here about my finding for DefaultUserName and DefaultDomainName registry keys in Windows7.
This shows the step to get rid of given warning message.
There is the difference in getting current logged on user on Windows Xp and Windows 7. This gives the method which works from current user context and doesn't need administrator privileges to get the current logged on user.
See http://www.eggheadcafe.com/sample-code/Windows7/e53b9d81-c025-4e41-a45c-f22214221c53/windows-7-uac-user-accou.aspx for UAC concept details. This shows how to disable it.
GetHostEntry on Windows 7 and .NET 3.5  (1599 Views)