.NET process failing DNS lookup with Windows 7
I have an application that is failing DNS lookup (System.Net.Dns.GetHostEntry) under windows 7. This application works fine under XP.
The error being generated is socket error code 11003:
WSANO_RECOVERY 11003
This is a nonrecoverable error. This indicates that some sort of nonrecoverable error occurred during a database lookup. This may be because开发者_C百科 the database files (for example, BSD-compatible HOSTS, SERVICES, or PROTOCOLS files) could not be found, or a DNS request was returned by the server with a severe error.
What is particularly interesting, is that this process is running directly from a network share. If I run it locally under Win 7, it works fine.
I have given the network location full trust under all versions of caspol (32 bit & 64bit).
Is there any other .NET or Windows 7 security setting that prevents DNS lookups by processes running from network shared locations?
Turns out this was caspol.
But on Windows 7, just being in the Administrators group is not enough.
You also have to right click the .NET Command Prompt shortcut and pick "Run as Administrator" to bypass UAC.
Then normal caspol commands will work.
Had a similar problem connecting to SQL Server via a .Net application running from a Network share.
With Win7/2008, you must Read, List Folder Contents on every folder from the share down to the application folder. If there is an intermediary folder without any permissions, the connection fails.
Works on XP.
If you are passing an IP address, it is worth noting that by default, it uses IPv6 and according to documentation, it will throw exception.
My suggestion is to get IPv4 address using the code below:
IPAddress ipv4 = Dns.GetHostAddresses(address).Where(x=>x.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault();
Ok, to easily test if your dns is configured correctly is to add a single html page in the root directory. If this page renders as expected, the dns is fine.
Everyone has his own way of checking things out, that's perfect because we can share our experiences. I like to put bits of my code/page to server pertaining to what I want to accomplish one bit at a time.
Hope this helps...
精彩评论