当前位置: 代码迷 >> ASP.NET >> IPHostEntry strIp = Dns.Resolve(Environment.MachineName);报错!
  详细解决方案

IPHostEntry strIp = Dns.Resolve(Environment.MachineName);报错!

热度:10701   发布时间:2013-02-26 00:00:00.0
IPHostEntry strIp = Dns.Resolve(Environment.MachineName);报错!!!
Page_load代码中写入如下代码:
String   hostIp;
                        hostIp   =   " ";
                        IPHostEntry   strIp   =   Dns.Resolve(Environment.MachineName);
                      //上面一句报错了。有一个警告。
                        for   (int   i   =   0;   i   <   strIp.AddressList.Length;   i++)
                                hostIp   +=   String.Format( "NetCard[{0}],IP={1}\n ",   i   +   1,   strIp.AddressList[i].ToString());
                        Response.Write(hostIp);

错误内容如下:
警告 1 “System.Net.Dns.Resolve(string)”已过时:“Resolve   is   obsoleted   for   this   type,   please   use   GetHostEntry   instead.   http://go.microsoft.com/fwlink/?linkid=14202” D:\BMSystem\BMMain\IpConfig.aspx.cs 25 38 http://localhost/BMSystem/


------解决方案--------------------------------------------------------
警告而已 不理它
  相关解决方案