Show the problem of C # listing 5.10 generated EXE file execution

Source: Internet
Author: User
Tags count execution
Problem | execution
Listing 5.10 Gets an IP address through an index

1:using System;
2:using System.Net;
3:
4:class Resolvedns
5: {
6:ipaddress[] m_arrips;
7:
8:public void Resolve (String strhost)
9: {
10:iphostentry Iphe = Dns.gethostbyname (strhost);
11:m_arrips = Iphe. AddressList;
12:}
13:
14:public IPAddress This[int Nindex]
15: {
16:get
17: {
18:return M_arrips[nindex];
19:}
20:}
21st:
22:public int Count
23: {
24:get {return m_arrips.length;}
25:}
26:}
27:
28:class Dnsresolverapp
29: {
30:public static void Main ()
31: {
32:resolvedns mydnsresolver = new Resolvedns ();
33:mydnsresolver.resolve ("http://www.microsoft.com");
34:
35:int ncount = Mydnsresolver.count;
36:console.writeline ("Found {0} IP ' for hostname", ncount);
37:for (int i=0 i < ncount; i++)
38:console.writeline (Mydnsresolver[i]);
39:}
40:}

Compilation Environment:

Visual Studio. NET2003 version 7.1.3091 Microsoft Visual C #. NET

Microsoft. NET Framework version 1.1.4322 SP1

Generated EXE file, error after execution:

An unhandled "System.Net.Sockets.SocketException" type of exception appears in the System.dll.

Additional information: The requested name is valid and were found in the database, but it does not have the correct associated data being re Solved for

What is this for? ......


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.