新手 问题请教
实现局域网计算机的搜索代码:
private void button3_Click(object sender, EventArgs e)
{
Thread thScan = new Thread(new ThreadStart(ScanTarget));
thScan.Start();
}
private void ScanTarget()
{
string strIpAddress = numericUpDown1.Value + "." + numericUpDown2.Value + "." + numericUpDown3.Value + ".";
int nStart = Int32.Parse(numericUpDown4.Value.ToString());
int nEnd = Int32.Parse(numericUpDown5.Value.ToString());
for (int i = nStart; i < nEnd; i++)
{
string strScanIpAdd = strIpAddress + i.ToString();
IPAddress myScanIp = IPAddress.Parse(strScanIpAdd);
try
{
IPHostEntry myScanHost = Dns.GetHostEntry(myScanIp);
string strHostName = myScanHost.HostName.ToString();
//richTextBox3.AppendText(strScanIpAdd+" "+strHostName+"\r");
this.SetText(strScanIpAdd + " " + strHostName + "\r");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
delegate void SetTextCallback(string text);
private void SetText(string text)
{
if (richTextBox3.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.richTextBox3.AppendText(text);
}
}
运行时出错
[] = {"请求的名称有效并且在数据库中找到,但是它没有相关的正确的数据来被解析。"}
请问这是什么原因造成的 ?该如何解决?
[[it] 本帖最后由 Y08M09D26 于 2008-9-27 14:12 编辑 [/it]]