NetworkInterface.GetAllNetworkInterfaces() still failing

HawkHawk USMember

Using Xamarin Studio 5.8.1 (build 8), Xamarin.Android 4.20.1.0, while trying to port a Java Android app to Xamarin C#, I am attempting to get the network adapter information. In my code I am calling:

NetworkInterface[] ni = NetworkInterface.GetAllNetworkInterfaces();

I am receiving the exception:
System.SystemException: getifaddrs() failed
at System.Net.NetworkInformation.LinuxNetworkInterface.ImplGetAllNetworkInterfaces () [0x00000] in :0
at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces () [0x00000] in :0

Searching this forum I found 3 other threads reporting the same issue, dating back to Feb to Mar 2013 with no reported resolution. One of the threads references a Bugzilla bug (https://bugzilla.xamarin.com/show_bug.cgi?id=1969) with a status of 'RESOLVED FIXED', but that doesn't appear to be in the current version of Xamarin Studio.

Is there a known fix available or a working solution to getting the NetworkInterface information?

Posts

  • HawkHawk USMember

    It's been a couple of days since this was posted. Does anyone have a suggested solution? Someone must have encountered this issue and and how to work around the failure, there has to be other Xamarin applications that are using the network interface.

    Thanks in advance.

  • HawkHawk USMember

    It's been a couple of days since this was posted. Does anyone have a suggested solution? Someone must have encountered this issue and and how to work around the failure, there has to be other Xamarin applications that are using the network interface.

    Thanks in advance.

  • RyanDavisRyanDavis ✭✭ AUInsider, University ✭✭

    @Hawk

    Just hit this on a 4.4.4 physical device. In my case on VS I don't see an exception, it just hangs indefinitely.
    No problems the 4.4 emulator and no problems on a 4.2.2 physical device I have here.

    As a workaround, for me Java.Net.NetworkInterface.NetworkInterfaces works OK - you can see some code using it here. There's also an extension method there that turns the java IEnumeration into an IEnumerable.

  • JGoldbergerJGoldberger Xamurai USMember, Forum Administrator, Xamarin Team, University Xamurai

    This seems to be fixed in the current Alpha channel. (Did not check Beta yet)

    Switching update channels
    In Xamarin Studio, you can switch the update channel with the Xamarin Studio->Check for Updates… menu, choosing Stable, Beta, or Alpha in the drop down next to Update Channel and then clicking the Switch Channel button.
    In Visual Studio, navigate to menu Tools->Options and scroll down to expand the Xamarin section and choose iOS (or Android) Settings. Choose Stable, Beta, or Alpha from the drop down menu and click Check Now. If updates to that channel are available, you will get a dialog similar to the above for Xamarin Studio. Proceed as above.

Sign In or Register to comment.