C# windows phone 8.1应用程序中的RouterResult.状态不断发出invalidcredentials错误消息

C# windows phone 8.1应用程序中的RouterResult.状态不断发出invalidcredentials错误消息,c#,xaml,windows-phone-8.1,C#,Xaml,Windows Phone 8.1,我对使用XAML编程相当陌生,我正在使用带有MapControl的WindowsPhone8.1仿真器为学校制作一个应用程序作为作业 昨天,我想画一条路线,并遵循本教程,效果很好。今天我再次运行了它,但它一直给我错误消息“InvalidCredentials”,带有routeResult.Status。我不知道为什么会出现这个错误 这是我使用的代码: public async void SetRouteDirectionsBreda() { string beginLoc

我对使用XAML编程相当陌生,我正在使用带有MapControl的WindowsPhone8.1仿真器为学校制作一个应用程序作为作业

昨天,我想画一条路线,并遵循本教程,效果很好。今天我再次运行了它,但它一直给我错误消息“InvalidCredentials”,带有routeResult.Status。我不知道为什么会出现这个错误

这是我使用的代码:

public async void SetRouteDirectionsBreda()
    {
        string beginLocation = "Willemstraat 17 Breda";
        string endLocation = "Reigerstraat 2 Breda";

        MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(beginLocation, map.Center);
        MapLocation begin = result.Locations.First();

        result = await MapLocationFinder.FindLocationsAsync(endLocation, map.Center);
        MapLocation end = result.Locations.First();

        List<Geopoint> waypoints = new List<Geopoint>();
        waypoints.Add(begin.Point);
        // Adding more waypoints later
        waypoints.Add(end.Point);

        MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(waypoints);

        Debug.WriteLine(routeResult.Status); // DEBUG

        if (routeResult.Status == MapRouteFinderStatus.Success)
        {
            MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
            viewOfRoute.RouteColor = Colors.Blue;
            viewOfRoute.OutlineColor = Colors.Black;

            map.Routes.Add(viewOfRoute);

            await map.TrySetViewBoundsAsync(routeResult.Route.BoundingBox, null, MapAnimationKind.Bow);
        }
        else
        {
            throw new Exception(routeResult.Status.ToString());
        }
    }
public异步void SetRouteDirectionsBreda()
{
字符串beginLocation=“Willemstraat 17 Breda”;
字符串endLocation=“Reigerstraat 2 Breda”;
MapLocationFinderResult=等待MapLocationFinder.FindLocationAsync(beginLocation,map.Center);
MapLocation begin=result.Locations.First();
结果=等待MapLocationFinder.FindLocationAsync(endLocation,map.Center);
MapLocation end=result.Locations.First();
列表航路点=新列表();
航路点。添加(起始点);
//稍后添加更多航路点
航路点添加(终点);
MapRouteFinderResult routeResult=等待MapRouteFinder.GetWalkingRouteFromWaypointsAsync(航路点);
Debug.WriteLine(routeResult.Status);//调试
if(routeResult.Status==MapRouteFinderStatus.Success)
{
MapRouteView viewOfRoute=新的MapRouteView(routeResult.Route);
viewOfRoute.RouteColor=Colors.Blue;
viewOfRoute.OutlineColor=Colors.Black;
map.Routes.Add(viewOfRoute);
wait map.TrySetViewBoundsAsync(routeResult.Route.BoundingBox,null,MapAnimationKind.Bow);
}
其他的
{
抛出新异常(routeResult.Status.ToString());
}
}

您应该在xaml页面中添加地图服务令牌,并将应用程序id添加到包清单中

有关向应用程序添加mapservicetoken的所有信息,请参见下面的链接。

我真的必须先买代币才能使用吗?有一天效果很好…看起来学生可以免费使用代币!谢谢我也有同样的问题,添加了每个令牌和Id,并且只在一些位置上得到这个错误,其他位置也在工作和显示路由