語言

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 方法會查詢網際網路 DNS 伺服器的主機資訊。 如果你傳遞空字串作為主機名稱,此方法會取得本地電腦的標準主機名稱。

對於非同步存取 DNS 資訊,請使用 and BeginGetHostByNameEndGetHostByName 方法。

若Ipv6Element.Enabled屬性設為 true,AliasesIPHostEntry回傳的實例屬性不會被此方法填充,且永遠為空。

Note

當您在應用程式中啟用網路追蹤時,該成員會發出追蹤資訊。 欲了解更多資訊,請參閱.NET框架中的網路追蹤。

適用於