0

在尝试实现两点之间的查找路线时,我使用了这篇文章,但它产生了错误:

找不到类型或命名空间名称“findroute”(您是否缺少 using 指令或程序集引用?)

using findroute.geocodeservice;
  private void Geocode(string strAddress, int waypointIndex)
    {
        // Here we create the service variable and set the callback method using the GeocodeCompleted property.
        findroute.geocodeservice.GeocodeServiceClient geocodeService = new findroute.geocodeservice.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
        geocodeService.GeocodeCompleted += new EventHandler<findroute.geocodeservice.GeocodeCompletedEventArgs>(geocodeService_GeocodeCompleted);
        // Here we Set the credentials and the geocode query,which could be an address or location.
        findroute.geocodeservice.GeocodeRequest geocodeRequest = new findroute.geocodeservice.GeocodeRequest();
        geocodeRequest.Credentials = new Credentials();
        geocodeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)map1.CredentialsProvider).ApplicationId;
        geocodeRequest.Query = strAddress;
        // Now Making the asynchronous Geocode request, using the 'waypoint index' as
        //   the user state to track this request and allow it to be identified when the response is returned.
        geocodeService.GeocodeAsync(geocodeRequest, waypointIndex);
    }

如何解决这个问题?

4

1 回答 1

5

您是否按照说明进行操作?

  • 转到解决方案资源管理器
  • 还要添加一个服务引用--> 右键单击​​引用

  • 添加服务参考

  • 在地址栏中输入 - http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex。这是为了在应用程序中使用 Route 相关的类。将此服务引用命名为routeservice.

  • 添加另一个服务引用http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex。这是为了在应用程序中使用 Geocode 相关的类。将此服务引用命名为geocodeservice.

给出的实际名称可能findroute.routeservice不仅仅是routeservice,但这基本上就是它要寻找的 - 使用您使用的任何名称相应地调整您的代码。

于 2012-04-16T21:35:26.797 回答