如何在Windows Phone 8.1模拟器中找到所有IP地址?

时间:2014-06-09 21:14:03

标签: windows-phone-8

在Windows Phone 8.1模拟器中,定义了几个网络接口,就像在Windows Phone 8中一样。在Windows Phone 8中,可以确定所有适配器的IP地址,其代码类似于以下内容: / p>

public static List<string> Find()
{
    List<string> ipAddresses = new List<string>();

    var hostnames = NetworkInformation.GetHostNames();
    foreach (var hn in hostnames)
    {
        if (hn.IPInformation != null)
        {
            string ipAddress = hn.DisplayName;
            ipAddresses.Add(ipAddress);
        }
    }

    return ipAddress;
}

乍一看,这似乎是this question的副本,或者甚至是this one的副本;但是,Windows Phone 8.1中的行为似乎已更改,因此在这些问题的答案中提供的代码不再可靠。在我的环境中,对于三个网络接口中的两个,IPInformation属性为null,而不是将IP地址作为名称,它们现在具有值Windows-Phone和{{1} }。如何在Windows Phone 8.1模拟器中找到所有网络适配器设备的IP地址?

0 个答案:

没有答案