1

Closed

Observable Ping - Unhandled Exception

description

When a string containing only numbers is used as an argument for ObservablePing.Send, an unhandled PingException is thrown instead of calling OnError.

using "123" results in the following.
System.Net.NetworkInformation.PingException occurred
  HResult=-2146233079
  Message=An exception occurred during a Ping request.
  Source=System
  StackTrace:
       at System.Net.NetworkInformation.Ping.SendAsync(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options, Object userToken)
       at System.Net.NetworkInformation.Ping.SendAsync(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options, Object userToken)
       at System.Net.NetworkInformation.Ping.SendAsync(String hostNameOrAddress, Int32 timeout, Byte[] buffer, Object userToken)
       at System.Net.NetworkInformation.Ping.SendAsync(String hostNameOrAddress, Object userToken)
       at System.Net.NetworkInformation.PingExtensions.<>c__DisplayClass4.<SendObservable>b__3(Object token)
       at System.Reactive.Linq.Observable2.FromEventBasedAsyncPattern[TDelegate,TEventArgs](Func`2 conversion, Action`1 addHandler, Action`1 removeHandler, Action`1 start, Action cancel, Action canceledOrCompleted)
       at System.Reactive.Linq.Observable2.FromEventBasedAsyncPattern[TDelegate,TEventArgs](Func`2 conversion, Action`1 addHandler, Action`1 removeHandler, Action`1 start, Action cancel)
       at System.Net.NetworkInformation.PingExtensions.CreatePingObservable(Ping ping, Action`1 start)
       at System.Net.NetworkInformation.PingExtensions.SendObservable(Ping ping, String hostNameOrAddress)
       at System.Net.NetworkInformation.ObservablePing.<>c__DisplayClass4.<Send>b__3(Ping ping)
       at System.Reactive.Linq.Observable2.UsingHot[TSource,TResource](TResource resource, Func`2 hotObservableFactory)
       at System.Net.NetworkInformation.ObservablePing.Send(String hostNameOrAddress)
       at ViewModel.EditConnectionViewModel.Ping() in c:\Projects\Code\ViewModel\EditConnectionViewModel.cs:line 206
  InnerException: System.ComponentModel.Win32Exception
       HResult=-2147467259
       Message=The network location cannot be reached. For information about network troubleshooting, see Windows Help
       Source=System
       ErrorCode=-2147467259
       NativeErrorCode=1231
       StackTrace:
            at System.Net.NetworkInformation.Ping.InternalSend(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options, Boolean async)
            at System.Net.NetworkInformation.Ping.SendAsync(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options, Object userToken)
       InnerException: 
Closed Oct 11, 2013 at 5:38 PM by davedev

comments

davedev wrote Oct 10, 2013 at 3:11 PM

Thanks for reporting this error.

wrote Oct 11, 2013 at 5:38 PM

Resolved with changeset 73152: Changed FromEventBasedAsyncPattern so that it protects calls to user code and to match the behavior of the native FromEvent* operators in Rx. Some of the calls to user code now being protected are made in the context of the operator's caller, so protecting them is not actually recommended per section 6.4 in the Rx Design Guidelines document; however, I've decided that consistency with related native operators is more important and there is probably a good reason that FromEvent* protects user code in the first place.