Dns.Resolve(String) 메서드

정의

주의

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

주의

Resolve has been deprecated. Use GetHostEntry instead.

주의

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

DNS 호스트 이름 또는 IP 주소를 IPHostEntry 인스턴스로 확인합니다.

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

매개 변수

hostName
String

DNS 스타일의 호스트 이름 또는 IP 주소입니다.

반환

hostName에 지정된 호스트의 주소 정보를 포함하는 IPHostEntry 인스턴스입니다.

특성

예외

hostName이(가) null인 경우

hostName의 길이가 255자를 넘습니다.

hostName을 확인할 때 오류가 발생한 경우

예제

다음 예제에서는 메서드를 Resolve 사용하여 IP 주소를 IPHostEntry instance resolve.

try
{
   IPHostEntry^ hostInfo = Dns::Resolve( hostString );
   
   // Get the IP address list that resolves to the host names contained in the
   // Alias property.
   array<IPAddress^>^address = hostInfo->AddressList;
   
   // Get the alias names of the addresses in the IP address list.
   array<String^>^alias = hostInfo->Aliases;
   Console::WriteLine( "Host name : {0}", hostInfo->HostName );
   Console::WriteLine( "\nAliases : " );
   for ( int index = 0; index < alias->Length; index++ )
   {
      Console::WriteLine( alias[ index ] );

   }
   Console::WriteLine( "\nIP Address list :" );
   for ( int index = 0; index < address->Length; index++ )
   {
      Console::WriteLine( address[ index ] );

   }
}
catch ( SocketException^ e ) 
{
   Console::WriteLine( "SocketException caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
catch ( ArgumentNullException^ e ) 
{
   Console::WriteLine( "ArgumentNullException caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
catch ( NullReferenceException^ e ) 
{
   Console::WriteLine( "NullReferenceException caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
catch ( Exception^ e ) 
{
   Console::WriteLine( "Exception caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
try {
    IPHostEntry hostInfo = Dns.Resolve(hostString);
    // Get the IP address list that resolves to the host names contained in the
    // Alias property.
    IPAddress[] address = hostInfo.AddressList;
    // Get the alias names of the addresses in the IP address list.
    String[] alias = hostInfo.Aliases;

    Console.WriteLine("Host name : " + hostInfo.HostName);
    Console.WriteLine("\nAliases : ");
    for(int index=0; index < alias.Length; index++) {
      Console.WriteLine(alias[index]);
    }
    Console.WriteLine("\nIP Address list :");
    for(int index=0; index < address.Length; index++) {
       Console.WriteLine(address[index]);
    }
 }
 catch(SocketException e)
 {
    Console.WriteLine("SocketException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(ArgumentNullException e)
 {
Console.WriteLine("ArgumentNullException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(NullReferenceException e)
 {
     Console.WriteLine("NullReferenceException caught!!!");
     Console.WriteLine("Source : " + e.Source);
     Console.WriteLine("Message : " + e.Message);
 }
 catch(Exception e)
 {
     Console.WriteLine("Exception caught!!!");
     Console.WriteLine("Source : " + e.Source);
     Console.WriteLine("Message : " + e.Message);
 }
Try
    ' Call the Resolve method passing a DNS style host name or an IP address in 
    ' dotted-quad notation (for example, "www.contoso.com" or "207.46.131.199") to 
    ' obtain an IPHostEntry instance that contains address information for the 
    ' specified host.
    Dim hostInfo As IPHostEntry = Dns.Resolve(hostString)
    ' Get the IP address list that resolves to the host names contained in the Alias 
    ' property.
    Dim address As IPAddress() = hostInfo.AddressList
    ' Get the alias names of the addresses in the IP address list.
    Dim [alias] As [String]() = hostInfo.Aliases

    Console.WriteLine(("Host name : " + hostInfo.HostName))
    Console.WriteLine(ControlChars.Cr + "Aliases : ")
    Dim index As Integer
    For index = 0 To [alias].Length - 1
        Console.WriteLine([alias](index))
    Next index
    Console.WriteLine(ControlChars.Cr + "IP Address list :")

    For index = 0 To address.Length - 1
        Console.WriteLine(address(index))
    Next index
Catch e As SocketException
    Console.WriteLine("SocketException caught!!!")
    Console.WriteLine(("Source : " + e.Source))
    Console.WriteLine(("Message : " + e.Message))
Catch e As ArgumentNullException
    Console.WriteLine("ArgumentNullException caught!!!")
    Console.WriteLine(("Source : " + e.Source))
    Console.WriteLine(("Message : " + e.Message))
Catch e As NullReferenceException
    Console.WriteLine("NullReferenceException caught!!!")
    Console.WriteLine(("Source : " + e.Source))
    Console.WriteLine(("Message : " + e.Message))
Catch e As Exception
    Console.WriteLine("Exception caught!!!")
    Console.WriteLine(("Source : " + e.Source))
    Console.WriteLine(("Message : " + e.Message))
End Try

설명

메서드는 Resolve DNS 서버에서 호스트 이름 또는 IP 주소와 연결된 IP 주소를 쿼리합니다.

가 여러 IP 주소와 연결된 DNS 스타일 호스트 이름인 경우 hostName 해당 호스트 이름으로 확인되는 첫 번째 IP 주소만 반환됩니다.

경우는 Ipv6Element.Enabled 속성이 , trueAliases 반환 된 instance 속성 IPHostEntry 이이 메서드에 의해 채워지지 않으며 항상 비어 있을 것입니다.

참고

이 멤버는 애플리케이션에서 네트워크 추적을 사용 하도록 설정 하면 추적 정보를 내보냅니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상