Async方法在Windows Phone 8.1上发生异常崩溃

时间:2015-11-04 08:50:12

标签: c# windows-phone-8.1

我使用Windows Phone 8.1的Map功能查找包含以下代码的路径:

MapRouteFinderResult routeResult = null;

try
{
    if (true == typeOfTransport.Equals(GlobalDeclarations.TypeOfTransport.Walk))
    {
        routeResult = await MapRouteFinder.GetWalkingRouteAsync(startPoint, endPoint);
    }
    else
    {
        routeResult = await MapRouteFinder.GetDrivingRouteAsync(startPoint, endPoint, MapRouteOptimization.Time, MapRouteRestrictions.None, 290);
    }
}
catch (Exception ex)
{
    System.Diagnostics.Debug.WriteLine(ex.Message);
}

问题是尽管有try-catch,但这个MapRouteFinder.GetWalkingRouteAsync方法崩溃并出现异常:Object not set to an instance of an objectstartPointendPoint参数都显然不为空,并且填充了数据。为什么是这样?为什么整个应用程序崩溃而不是在try-catch部分中捕获异常?

0 个答案:

没有答案