Bug 6312 - System.Net.NetworkInformation.Ping.Send() throws IOE
Summary: System.Net.NetworkInformation.Ping.Send() throws IOE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.2.x
Hardware: PC Mac OS
: Low normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-07-27 17:46 UTC by Jonathan Pryor
Modified: 2013-09-19 20:01 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2012-07-27 17:46:35 UTC
Moved from #6308.

The following code throws System.InvalidOperationException:

	var x = new System.Net.NetworkInformation.Ping ();
	var r = x.Send ("google.com");
	Console.WriteLine ("r.Status={0}", r.Status);

Expected result: no exception.

Actual result:

> UNHANDLED EXCEPTION: System.InvalidOperationException: Process has not been started.
> at System.Diagnostics.Process.get_HasExited () <0x0008c>
> at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.get_HasExited () <0x0005f>
> at System.Net.NetworkInformation.Ping.SendUnprivileged (System.Net.IPAddress,int,byte[],System.Net.NetworkInformation.PingOptions) <0x0043b>
> at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress,int,byte[],System.Net.NetworkInformation.PingOptions) <0x0009b>
> at System.Net.NetworkInformation.Ping.Send (string,int,byte[],System.Net.NetworkInformation.PingOptions) <0x00053>
> at System.Net.NetworkInformation.Ping.Send (string,int,byte[]) <0x0004b>
> at System.Net.NetworkInformation.Ping.Send (string,int) <0x0002f>
> at System.Net.NetworkInformation.Ping.Send (string) <0x0001f>
> at (wrapper remoting-invoke-with-check) System.Net.NetworkInformation.Ping.Send (string) <0x00073>
> at Bxc6308.Ping.Activity1.OnCreate (Android.OS.Bundle) <0x000ef>
> at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00057>
> at (wrapper dynamic-method) object.a2d2eae3-3268-4fc7-8b3f-c061a8baf930 (intptr,intptr,intptr) <0x00033>
Comment 1 Atsushi Eno 2012-08-07 06:04:51 UTC
mono's Ping implementation on non-Windows depends on local ping command existence. Maybe we need to explicitly specify "/system/bin/ping" in Android case?
Comment 2 Atsushi Eno 2012-09-07 07:57:31 UTC
With my fix https://github.com/mono/mono/commit/99d5e54c (and mm) it correctly invokes /system/bin/ping now, but I only receive TtlExpired. I'm not sure if this is the expected result. Maybe not.
Comment 3 Tommy Baggett 2013-09-17 17:59:22 UTC
This defect is listed as fixed in Xamarin.Android 4.6 (http://docs.xamarin.com/releases/android/xamarin.android_4/xamarin.android_4.6).  

Has this been fixed?
Comment 4 Jonathan Pryor 2013-09-18 16:01:32 UTC
> Has this been fixed?

It has been "fixed" such that /system/bin/ping will be used if present. If not present, then the InvalidOperationException will still be generated.
Comment 5 Tommy Baggett 2013-09-19 20:01:21 UTC
Cool, thanks for explaining, Jonathan.  After trying several different approaches to ping a URL without depending on the flakey, I came up with a solution using URLConnection that is working correctly on the devices I've tested so far.  

Any thoughts on whether or not using URLConnection will be more dependable than ping on Android?  See my comment at http://forums.xamarin.com/discussion/comment/27260/#Comment_27260 for a code example of it in use.
Comment 6 Tommy Baggett 2013-09-19 20:01:55 UTC
"...on the flakey ping command" I meant to say.