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