1

I'm trying to show a route from point-to-point on the bing-maps (testing on real device). I've entered 2 waypoints (GeoCoordinate) and I'm trying to get the route via the Windows PhoneToolKit using the await query.GetRouteAsync(). Unfortunately, I'm getting an unknown error:

The result of the async call:

'e.Result' threw an exception of type 'System.Reflection.TargetInvocationException'

The inner exception:

Exception from HRESULT: 0x8004231C

I've checked the MSDN website and noticed that this errorcode is not listed in the errorlist...

The related code is below. I've used the exact same code as in the sample set of the Windows Phone Toolkit, but removed the things which has nothing to do with getting the route:

    private async void BtnShowRoute_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        try
        {
            RouteQuery query = new RouteQuery();
            List<GeoCoordinate> wayPoints = new List<GeoCoordinate>();

            wayPoints.Add(new GeoCoordinate(47.23449, -121.172447));
            wayPoints.Add(new GeoCoordinate(47.062638, -120.691795));

            query.Waypoints = wayPoints;

            Route route = await query.GetRouteAsync();

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            throw;
        }
    }

I have no idea what is going wrong here. Does anyone else experienced this issue? If so, did you resolve it? And how?

Note: I'm running Windows Phone 8.1. Dev Preview

Community
  • 1
  • 1
pazcal
  • 929
  • 5
  • 26
  • Have you found an answer to this? I'm walking through a tutorial on creating a run tracking app, and I'm running into the same error. – tmoore82 May 20 '14 at 00:36
  • Unfortunately not... Also on the MSDN website I haven't received any response. ATM I'm waiting till the 8.1 is officially released and pushed to all the 8.0 phones and hope that it will be resolved. – pazcal May 27 '14 at 13:41

1 Answers1

1

This happens when the underlying service call times out before completing the query. Hopefully this will be fixed in next version , but for now you can use following code:

private async void BtnShowRoute_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
            RouteQuery query = new RouteQuery();
            List<GeoCoordinate> wayPoints = new List<GeoCoordinate>();

            wayPoints.Add(new GeoCoordinate(47.23449, -121.172447));
            wayPoints.Add(new GeoCoordinate(47.062638, -120.691795));

            query.Waypoints = wayPoints;
   query .QueryCompleted += geoQ_QueryCompleted;
            query.GetRouteAsync();


    }  
 private void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {
            try
            {
                Route myRoute = e.Result;
            }
            catch (TargetInvocationException)
            {
                Thread.Sleep(1000); // waiting for  completing the query
                    geoQ_QueryCompleted(sender, e);
            }

        }