Dns.GetHostByName(String) Metod

Definition

Varning

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

Varning

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

Hämtar DNS-informationen för det angivna DNS-värdnamnet.

public:
 static System::Net::IPHostEntry ^ GetHostByName(System::String ^ hostName);
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);
[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);
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
[<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
Public Shared Function GetHostByName (hostName As String) As IPHostEntry

Parametrar

hostName
String

Värdens DNS-namn.

Returer

Ett IPHostEntry objekt som innehåller värdinformation för den adress som anges i hostName.

Attribut

Undantag

hostName är null.

Längden hostName på är större än 255 tecken.

Ett fel påträffas när du löser hostName.

Kommentarer

Metoden GetHostByName frågar Internet DNS-servern efter värdinformation. Om du skickar en tom sträng som värdnamn hämtar den här metoden standardvärdnamnet för den lokala datorn.

Använd metoderna och EndGetHostByName för asynkron åtkomst till DNS-informationBeginGetHostByName.

Om egenskapen Ipv6Element.Enabled är inställd på trueAliases fylls egenskapen för den returnerade instansen IPHostEntry inte med den här metoden och kommer alltid att vara tom.

Note

Den här medlemmen genererar spårningsinformation när du aktiverar nätverksspårning i ditt program. Mer information finns i Network Tracing in .NET Framework.

Gäller för