Select to view content in your preferred language

IdentityTask Error

667
1
03-05-2012 10:13 AM
ChadBartman
Deactivated User
Hello,
I am new to development and I am attempting to utilize the Identify Task and am running in to problem.
The code was obtained at the following url:
http://help.arcgis.com/en/webapi/silverlight/help/index.html#/Identify_task/01660000001m000000/

When I debug I receive the following error:
NullReferenceException was handeled by user code.
Object reference not set to an instance of an object.

     private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs args)
            {
                GraphicsLayer graphicsLayer = MyMap.Layers["IdentifyIconGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();
                ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
                {
                    Geometry = args.MapPoint,
                    Symbol = LayoutRoot.Resources["IdentifyLocationSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
                };
                graphicsLayer.Graphics.Add(graphic);
                IdentifyTask identifyTask = new IdentifyTask("http://geoservices.dnr.illinois.gov/ArcGIS/rest/services" +
                "WHPTS/MapServer");
                identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
                identifyTask.Failed += IdentifyTask_Failed;
                IdentifyParameters identifyParameters = new IdentifyParameters();
                identifyParameters.LayerOption = LayerOption.all;
                identifyParameters.MapExtent = MyMap.Extent;
                identifyParameters.Width = (int)MyMap.ActualWidth;
                identifyParameters.Height = (int)MyMap.ActualHeight;
                identifyParameters.Geometry = args.MapPoint;
                identifyTask.ExecuteAsync(identifyParameters);
            }
            private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
            {
                IdentifyComboBox.Items.Clear();
                if (args.IdentifyResults.Count > 0)



What am I doing that is wrong?
Thanks
0 Kudos
1 Reply
DarinaTchountcheva
Frequent Contributor
Chad,

I believe the problem is in a missing "/" after "services":

IdentifyTask identifyTask = new IdentifyTask("http://geoservices.dnr.illinois.gov/ArcGIS/rest/services" +
"WHPTS/MapServer");


Try this:

IdentifyTask identifyTask = new IdentifyTask("http://geoservices.dnr.illinois.gov/ArcGIS/rest/services/" +
"WHPTS/MapServer");


If this is not the problem, please, tell us what line of code causes the error.

Good Luck!
0 Kudos