我在写一个 索引 获取IP地址
程序如下:using System;
using System.Net;    //编译时提示没有这个名字空间,(不明白为什么是我写错了吗)class ResolveDNS
{
    IPAddress[] m_arrIPs;    public void Resolve(string strHost)
    {
        IPHostEntry iphe = DNS.GetHostByName(strHost);
        m_arrIPs = iphe.AddressList;
    }    public IPAddress this[int nIndex]
    {
        get
        {
            return m_arrIPs[nIndex];
        }
    }
    public int Count
    {
        get
        {
            return m_arrIPs.Length;
        }
    }
}
class DNSResoverAppp
{
    public static void Main()
    {
        ResolveDNS myDNSResolver = new ResolveDNS();
        myDNSResolver.Resolve("http://www.microsoft.com");        int nCount = myDNSResolver.Count;
        Console.WriteLine("Found{0}IP's for houstname", nCount);        for (int i; i < nCount; i++)
            Console.WriteLine(myDNSResolver[i]);
    }
}//现在这个程序 不能运行 提示没有  System.Net;   名字空间 可是这个空间是对的阿,现在有点晕,希望高手 指点~!!谢谢了

解决方案 »

  1.   

    Namespace: System.NetPlatforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact FrameworkAssembly: System (in System.dll).NET Framework Security:  DnsPermission to allow the use of Dns.
      

  2.   

    IPHostEntry iphe = DNS.GetHostByName(strHost);
    改成:
    IPHostEntry iphe = Dns.GetHostByName(strHost);
      

  3.   

    是你没有引入system吗?应该不会出现你说的情况呀,这个命名控件在system.dll中呀