0

您是否有任何想法更改代碼並避免使用MapToIPv4,因爲我的電腦是Visual Studio 2010?Visual Studio 2010 MapToIPv4

hostIP = ipHostInfo.AddressList(CType(logNconfig.Addresslist.ToString(), Integer)) 
    TxtIP.Text = hostIP.MapToIPv4.ToString() 

    hostIP = System.Net.IPAddress.Parse(TxtIP.Text) 

    server = Nothing 
    server = New TcpListener(hostIP, TxtPort.Text) 

    server.Start() 

你有任何想法解決這個? :(我想運行它的Visual Studio 2010 ..

+0

*您可能*去看看[參考來源](HTTP:// referencesource。 microsoft.com/#System/net/System/Net/IPAddress.cs,cae19ee54c742f78)。但是,有一個問題 - 代碼實際上是錯誤的,所以你實際上也想檢查[這個問題/答案](http:/ /stackoverflow.com/questions/23608829/why-does-ipaddress-maptoipv4-throw-argumentoutofrangeexception) –

回答

0

您可以檢索名稱IP地址使用 Dim hostname As String = Dns.GetHostName() Dim ipaddress As String = CType(Dns.GetHostEntry(hostname).AddressList.GetValue(0), IPAddress).ToString View Sample