ArcGIS API for Microsoft Silverlight 2.0 using ArcGis 9.3.1 release of the map servic

2735
17
08-19-2010 02:33 AM
leosnowmaple
New Contributor
ArcGIS API for Microsoft Silverlight 2.0 using ArcGis server 9.3.1 release of the map service problems: the current release of the map with ArcGis 9.3.1 service

delivery network of services (NAServer), in the ArcGIS API for Microsoft Silverlight 1.2 version to access all normal, using the new ArcGIS API for

Microsoft Silverlight 2.0 release, VS 2010 development environment, the access to these services made possible by routing error: error solving route,

unable to find attribute invalid context! ! Error, how to solve? ArcGIS API for Microsoft Silverlight 2.0 is designed for arcgis server 10 to access the

service may indeed release 9.3.1 problems? ?
0 Kudos
17 Replies
dotMorten_esri
Esri Notable Contributor
v2.0 is compatible with AGS9.3.1, but does offer new routing functionality that was not available in 9.3.1 (so stay clear of those added features).
Could you share some code? It's really hard to guess what the problem could be.
0 Kudos
leosnowmaple
New Contributor
Maybe I did not make things clear, I am not saying that the map server 10 service release new features, currently I use the test code is InteractiveSDKSource of network analysis applications RoutingBarriers instance! The examples in the previous 1.2 version, I use their web analytics service release is run, and now upgrade to ArcGIS API for Microsoft Silverlight 2.0, the access to the same analysis of their published web services error, error message is: outing error: error solving route, unable to find attribute invalid context!! ask is what causes, how to solve? ? ! !
0 Kudos
dotMorten_esri
Esri Notable Contributor
Again I cannot guess what is wrong if you don't share some code, or the requests going between the browser and the server.
0 Kudos
leosnowmaple
New Contributor
Sample - Interactive SDK to use the online map services (map service, network analysis services) is currently in the ArcGIS API for Microsoft Silverlight Interactive SDK is used in the 2.0 release of the service ARCGIS SERVER 10, right? For example: procedures used in network analysis service, http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route I use ARCGIS SERVER 9.3.1 release of the service, currently using the following code Access Times of the wrong: error message is: outing error: error solving route, unable to find attribute invalid context!!

Path analysis of the full code is as follows (in the API 1.2 use of normal):
0 Kudos
leosnowmaple
New Contributor
XAML:
<UserControl x:Class="ArcGISSilverlightSDK.RoutingBarriers"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="StopSymbol" Size="20" Style="Circle" Color="Salmon" >
                <esri:SimpleMarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid>
                            <Ellipse Fill="{Binding Symbol.Color}" Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}" Stroke="Black" StrokeThickness="1" />
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
                                Text="{Binding Path=Attributes[StopNumber]}"
                                FontSize="9" Margin="0" FontWeight="Bold" Foreground="Black" />
                        </Grid>
                    </ControlTemplate>
                </esri:SimpleMarkerSymbol.ControlTemplate>
            </esri:SimpleMarkerSymbol>
            <esri:SimpleMarkerSymbol x:Key="BarrierSymbol" Size="15" Style="Square" Color="Red"  />
            <esri:SimpleLineSymbol x:Key="RouteSymbol" Color="#990000FF" Width="5"/>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Background="White" Extent="-117.22,34.04,-117.17,34.07"
      MouseClick="MyMap_MouseClick" >
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer
                      Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
                <esri:GraphicsLayer ID="MyRouteGraphicsLayer" />
                <esri:GraphicsLayer ID="MyStopsGraphicsLayer" />
                <esri:GraphicsLayer ID="MyBarriersGraphicsLayer" />
            </esri:Map.Layers>
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" >
            <Rectangle Fill="#77919191" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <StackPanel Orientation="Horizontal" Margin="5">
                <RadioButton Content="Add Stops" x:Name="StopsRadioButton" IsChecked="true" 
      Foreground="White" GroupName="add" VerticalAlignment="Center" />
                <RadioButton Content="Add Barriers" x:Name="BarriersRadioButton"
      Foreground="White" GroupName="add" VerticalAlignment="Center" />
                <Button Content="Clear" Click="Button_Click" Margin="5,0,0,0"/>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
0 Kudos
leosnowmaple
New Contributor
code behind c#:
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Tasks;

namespace ArcGISSilverlightSDK
{
    public partial class RoutingBarriers : UserControl
    {
        RouteTask _routeTask;
        List<Graphic> _stops = new List<Graphic>();
        List<Graphic> _barriers = new List<Graphic>();
        RouteParameters _routeParams = new RouteParameters();

        public RoutingBarriers()
        {
            InitializeComponent();

            _routeTask =
                new RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route");
            _routeTask.SolveCompleted += routeTask_SolveCompleted;
            _routeTask.Failed += routeTask_Failed;

            _routeParams.Stops = _stops;
            _routeParams.Barriers = _barriers;
            _routeParams.UseTimeWindows = false;
        }

        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            if (StopsRadioButton.IsChecked.Value)
            {
                GraphicsLayer stopsLayer = MyMap.Layers["MyStopsGraphicsLayer"] as GraphicsLayer;
                Graphic stop = new Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["StopSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol };
                stop.Attributes.Add("StopNumber", stopsLayer.Graphics.Count + 1);
                stopsLayer.Graphics.Add(stop);
                _stops.Add(stop);
            }
            else if (BarriersRadioButton.IsChecked.Value)
            {
                GraphicsLayer stopsLayer = MyMap.Layers["MyBarriersGraphicsLayer"] as GraphicsLayer;
                Graphic barrier = new Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["BarrierSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol };
                stopsLayer.Graphics.Add(barrier);
                _barriers.Add(barrier);
            }
            if (_stops.Count > 1)
            {
                if (_routeTask.IsBusy)
                    _routeTask.CancelAsync();
                _routeTask.SolveAsync(_routeParams);
            }
        }

        private void routeTask_Failed(object sender, TaskFailedEventArgs e)
        {
            string errorMessage = "Routing error: ";
            errorMessage += e.Error.Message;
            foreach (string detail in (e.Error as ServiceException).Details)
                errorMessage += "," + detail;

            MessageBox.Show(errorMessage);
            GraphicsLayer graphicsLayer = MyMap.Layers["MyStopsGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.RemoveAt(graphicsLayer.Graphics.Count - 1);
        }

        private void routeTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer routeLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            RouteResult routeResult = e.RouteResults[0];
            routeResult.Route.Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            routeLayer.Graphics.Clear();
            Graphic lastRoute = routeResult.Route;

            routeLayer.Graphics.Add(lastRoute);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _stops.Clear();
            _barriers.Clear();

            foreach (Layer layer in MyMap.Layers)
                if (layer is GraphicsLayer)
                    (layer as GraphicsLayer).ClearGraphics();
        }
    }
}
0 Kudos
leosnowmaple
New Contributor
Morten Nielsen (SharpGIS):
         Hello!
     Code is also posted, to see what the problem is how to solve? ! How ArcGIS API for Microsoft Silverlight 2 release access ARCGIS SERVER 9.3.1 Network analysis services, which are not error, normal use .....
0 Kudos
RobertDolormente
New Contributor
Any solution for this? I'm running into the same issue. I'm trying to take advantage of the new features with Silverlight 4 and ArcGIS API for Silverlight 2.1 but the route task doesn't seem to like the 9.3.1 Route map service. Getting the following error: "Error solving route, unable to find attribute. Invalid context." If I revert to ArcGIS API for Silverlight 1.0 it works fine but can't use new features like the legend. Any ideas?
0 Kudos
JenniferNery
Esri Regular Contributor
Are you using the same url? http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer. This seems to be a broken link and might be what causes the issue? Also the version of http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis seem updated to 10.01.
0 Kudos