我的程序使用IPHostEntry和DNS,我知道我必須添加System.Object,System.Net.IPHostEntry,System.Net.DNS到我的項目引用,但我無法在列表中找到它。什麼是IPHostEntry和DNS的正確命名空間?
在System.IO.Log之後,接下來是System。管理(無System.Object的)
的System.Net後System.Numerics(無System.Net.IPHostEntry或System.Net.DNS)
我使用.NET 4.0
做什麼我確實要添加以下參考並使其工作?
我有以下代碼
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Windows.Forms;
public string LocalIPAddress()
{
IPHostEntry host;
string localIP = "";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
break;
}
}
return localIP;
}
'System.Object'不是一個命名空間。這是一堂課。誰讓你添加這樣的參考?現在有什麼問題?你的代碼是不是編譯? – horgh
我不能添加system.object當我添加它的對象變成藍色與紅色的波浪線 –
好吧,我認爲我得到它對象上的帽「O」是問題...對於麻煩先生抱歉。 –