语言

Dns.GetHostByName(String) 方法

定义

注意

GetHostByName has been deprecated. Use GetHostEntry instead.

注意

GetHostByName is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202

注意

GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202

获取指定 DNS 主机名的 DNS 信息。

public:
 static System::Net::IPHostEntry ^ GetHostByName(System::String ^ hostName);
[System.Obsolete("GetHostByName has been deprecated. Use GetHostEntry instead.")]
public static System.Net.IPHostEntry GetHostByName(string hostName);
[System.Obsolete("GetHostByName is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByName(string hostName);
[System.Obsolete("GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByName(string hostName);
public static System.Net.IPHostEntry GetHostByName(string hostName);
[<System.Obsolete("GetHostByName has been deprecated. Use GetHostEntry instead.")>]
static member GetHostByName : string -> System.Net.IPHostEntry
[<System.Obsolete("GetHostByName is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")>]
static member GetHostByName : string -> System.Net.IPHostEntry
[<System.Obsolete("GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
static member GetHostByName : string -> System.Net.IPHostEntry
static member GetHostByName : string -> System.Net.IPHostEntry
Public Shared Function GetHostByName (hostName As String) As IPHostEntry

参数

hostName
String

主机的 DNS 名称。

返回

一个 IPHostEntry 对象,该对象包含指定 hostName地址的主机信息。

特性

例外

hostName 是 null。

长度 hostName 大于 255 个字符。

解析 hostName时遇到错误。

注解

该方法 GetHostByName 查询 Internet DNS 服务器以获取主机信息。 如果将空字符串作为主机名传递,此方法将检索本地计算机的标准主机名。

若要异步访问 DNS 信息,请使用 BeginGetHostByName 和 EndGetHostByName 方法。

Ipv6Element.Enabled如果该属性设置为 true,Aliases则返回的IPHostEntry实例的属性不会由此方法填充,并且始终为空。

注释

在应用程序中启用网络跟踪时,此成员会发出跟踪信息。 有关详细信息,请参阅 .NET Framework 中的 Network Tracing。

适用于