deshaw
asked on
Dns.GetHostEntry(string.Empty).HostName failing
Hi Experts,
I have noticed that on one of our citrix server Dns.GetHostEntry(string.Em pty).HostN ame failing with the below error message
Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubS tringWithC hecks(Int3 2 startIndex, Int32 length, Boolean fAlwaysCopy)
We have deployed our application to 1000s machines including some of citrix servers and they dont have any problems with this. I dont know why this error is occuring only one citrix server. Could you please tell me what could be wrong.
Please dont suggest anything else except solution to this problem because our application is already in production to 1000s machine and we can not change the application. There must be a some problem with machine but we dont know. If we figured out how Dns.GetHostEntry(string.Em pty).HostN ame works then probably we can nail down the problem.
This problem's solution definately deserves 500 points.
Thanks.
I have noticed that on one of our citrix server Dns.GetHostEntry(string.Em
Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubS
We have deployed our application to 1000s machines including some of citrix servers and they dont have any problems with this. I dont know why this error is occuring only one citrix server. Could you please tell me what could be wrong.
Please dont suggest anything else except solution to this problem because our application is already in production to 1000s machine and we can not change the application. There must be a some problem with machine but we dont know. If we figured out how Dns.GetHostEntry(string.Em
This problem's solution definately deserves 500 points.
Thanks.
ASKER
Hello,
Could anyone can take up this task. It is very important for us. Now I am having only one question. Why
Console.WriteLine("The FQDN host name is : " + Dns.GetHostEntry(string.Em pty).HostN ame); prints just host name. Actually it prints "hostname.site.domain.com" in FQDN format but we have some hosts where it gives only "hostname" and that causing the problem.
Is it related to TCP IP parameters in registry??
Thanks.
Could anyone can take up this task. It is very important for us. Now I am having only one question. Why
Console.WriteLine("The FQDN host name is : " + Dns.GetHostEntry(string.Em
Is it related to TCP IP parameters in registry??
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks but the problems was in hosts file. We have solved it in https://www.experts-exchange.com/questions/23812130/Why-GetHostEntry-behaviour-is-different.html
ASKER
thanks but this was not useful.
ASKER
For more info. I am using this function like below:
try {
//The GetHostEntry method queries a DNS server for the IP address that is associated with a host name or IP address.
//When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host.
string hostFullName = Dns.GetHostEntry(string.Em
localHostName = hostFullName.Substring(0, hostFullName.IndexOf("."))
hostFullName = hostFullName.Substring(hos
localSiteName = hostFullName.Substring(0, hostFullName.IndexOf("."))
topDomain = hostFullName.Substring(hos
} catch(Exception ex) {
Globals.LogHandler.Debug("
MessageBox.Show("Could not retrieve local site, host and top domain names.", "UNIX Chooser",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
So it may possible that given error occures in SubString because GetHostEntry has not returned any value.
Thanks.