Per Xamarin Support:
Looks like I have some bad news: http://forums.xamarin.com/discussion/1706/system-net-networkinformation-getallnetworkinterfaces-fails It's a known bug that hasn't been addressed. You will have to make native calls to find out the network interface iOS:
http://docs.xamarin.com/recipes/ios/network/reachability/detect_if_network_is_available For this kind of device specific code, you can look at using Compiler Directives #if / #endif Building Cross Platform Applications - check out part 3 and part 5 for practical setups. you can also check our sample apps for how to configure your projects.
So here's what I ended up doing:
try
{
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (var netInterface in interfaces)
{
if ((netInterface.OperationalStatus == OperationalStatus.Up ||
netInterface.OperationalStatus == OperationalStatus.Unknown) &&
(netInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
netInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet))
{
foreach (var addrInfo in netInterface.GetIPProperties().UnicastAddresses)
{
if (addrInfo.Address.AddressFamily == AddressFamily.InterNetwork)
{
var ipAddress = addrInfo.Address;
CurrentAddressTable.Add(ipAddress);
}
}
}
}
}
catch (Exception ex)
{
Helper.Debug(ex.ToString());
}
Since Xamarin's implementation does not set the NetworkInterface.OperationalStatus, I am forced to allow either 'Up' or 'Unknown' to be accepted. Although this approach works on Windows and on iOS, it does not work on Android devices. It is frustrating that such a simple thing as getting a valid Local IP address should be so difficult. But I guess this is the way things are at this point.