WCF/C# Unable to catch EndpointNotFoundException

前端 未结 5 1456
北荒
北荒 2021-01-07 23:09

I have created a WCF service and client and it all works until it comes to catching errors. Specifically I am trying to catch the EndpointNotFoundException for

5条回答
  •  梦谈多话
    2021-01-07 23:35

    Place a try catch block in the CompletedMethod.

    An Example:

    ...
    geocodeService.ReverseGeocodeCompleted += ReverseGeocodeCompleted(se, ev);
    geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
    }
    
        private void ReverseGeocodeCompleted(object sender, ReverseGeocodeCompletedEventArgs e)
        {
          try
            {
                // something went wrong ...
                var address = e.Result.Results[0].Address;
    
            }
            catch (Exception)
            { // Catch Exception
                Debug.WriteLine("NO INTERNET CONNECTION");
            }
    

提交回复
热议问题