System.Net.NetworkInformation IPv4Mask 在 MonoTouch 中不起作用? [英] System.Net.NetworkInformation IPv4Mask not working in MonoTouch?

查看:36
本文介绍了System.Net.NetworkInformation IPv4Mask 在 MonoTouch 中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码获取 iPhone 上当前可用的网络接口列表:

I use the following code to get a list of network interfaces currently available on the iPhone:

foreach (NetworkInterface l__objNetworkInterface in NetworkInterface.GetAllNetworkInterfaces())
{
    foreach (UnicastIPAddressInformation l__objIPAddress in l__objNetworkInterface.GetIPProperties().UnicastAddresses)
    {
        if (l__objAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
        {
            if (l__objAddress.IPv4Mask != null) Console.WriteLine("IPv4 Mask: " + l__objAddress.IPv4Mask.ToString());
        }
    }
}

我的问题:调用属性 IPv4Mask 似乎阻塞了代码(IPv4Mask 永远不会输出到控制台,iPhone 模拟器似乎在调用点停止处理).

My Problem: Calling the property IPv4Mask seems to block the code (the IPv4Mask is never output to the console and the iPhone-Simulator seems to stop processing at the calling point).

有人知道这个问题吗?IPv4Mask 属性是否未在单点触控中实现(我在单点触控或谷歌上找不到任何关于此的明确信息)?

Does anyone know this problem? Is the IPv4Mask property not implemented in monotouch (I can't find any clear infos about this on monotouch or google)?

推荐答案

IPv4Mask 未实现单播中的 UnicastIPAddresses.

The IPv4Mask is not implemented for UnicastIPAddresses in mono.

您的代码似乎也有错别字,您在第二个 foreach 中循环了 l__objIPAddress,但随后您在循环中访问了 l__objAddress.

You also seem to have a typo in your code, you loop over l__objIPAddress in your second foreach, but then you access l__objAddress inside the loop.

这篇关于System.Net.NetworkInformation IPv4Mask 在 MonoTouch 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆