Select to view content in your preferred language

System.ArgumentException occurred in ESRI.ArcGIS.Client

1763
3
04-18-2012 11:46 PM
KumaranMuthusamy
New Contributor
I have developed Silverlight application using ArcGIS API for Silverlight v1.2 and VS2008. Now I upgraded this application to ArcGIS API for Silverlight v2.4 and VS2010. After this upgrade I am getting below error while loading map layers and associated params like TOC and coordinate system.

An exception of type 'System.ArgumentException' occurred in ESRI.ArcGIS.Client but was not handled in user code
Additional information: 'Url' is not set.

If i click continue in this error message, i am getting another error message in browser. Please refer the attached screen shot.
Please help me to solve this issue.

Thanks,
M.Kumaran.
0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor
For quite a while now, it's required that the Url property is set prior to initializing the layer.
0 Kudos
by Anonymous User
Not applicable
Original User: giskumaran

For quite a while now, it's required that the Url property is set prior to initializing the layer.


Hi,
I have set the url property prior to initializing the layer (Please check the below code). But, still i am getting this error while loading associated params for Map.

  #region Load dynamic services
                //for (int ServiceCount = 0; ServiceCount < MapUtility.GetServiceItems().Count; ServiceCount++)
                //{
                if (MapUtility.GetServiceItems()[intServiceCount].ServiceType.ToLower().Equals(MapBusinessConstants.DYNAMICSERVICETYPE.ToLower()) &&
                    (MapUtility.GetServiceItems()[intServiceCount].IsRequired.ToLower().Equals("1") || MapUtility.GetServiceItems()[intServiceCount].IsRequired.ToLower().Equals("yes")))
                {

                    objDynamicLayer = new ArcGISDynamicMapServiceLayer();

                    objDynamicLayer.ID = MapUtility.GetServiceItems()[intServiceCount].Title;
                    objDynamicLayer.Url = MapUtility.GetServiceItems()[intServiceCount].MapServiceUrl;
                    objDynamicLayer.InitializationFailed += (evtsender, args) =>
                    {
                        Layer objLayer = evtsender as ArcGISDynamicMapServiceLayer;
                        objLayerNotLoaded.Add(objLayer.ID);
                        objMap.Layers.Remove(objLayer);
                        objMapPage.canvasMyProgressbar.Visibility = Visibility.Collapsed;
                        System.Windows.Browser.HtmlPage.Window.Alert(string.Format("Layer '{0}' {1}", objLayer.ID, MapExceptions.MAPRESOURCEERRORMESSAGE));
                    };

                    objDynamicLayer.Initialized += (evtsender, args) =>
                    {
                        if (blnIsSetMapunit == false)
                        {
                            if (objDynamicLayer.Units != null)
                            {
                                MapBusinessConstants.MAPUNIT = Convert.ToString((esriUnits)Enum.Parse(typeof(esriUnits), objDynamicLayer.Units, true));
                                blnIsSetMapunit = true;
                                MapUtility.SetMapUnit(MapBusinessConstants.MAPUNIT);
                            }
                        }
                    };
                    objMap.Layers.Add(objDynamicLayer);                  
                }
            }
#endregion
0 Kudos
JenniferNery
Esri Regular Contributor
It's hard to tell where this exception is thrown even with the code snippet you shared. It might be helpful to run fiddler and/or put breakpoints to see the program flow right before this exception is thrown. Generally speaking, if the layer's Url property is set before it gets added to your map and/or before it gets initialized, this error should not be thrown. Be sure also to subscribe to Initialized/InitializationFailed events before layer is added to your map and/or initialization occurs. Check for layer.InitializationFailure (if null). The following blog post might help: http://blogs.esri.com/esri/arcgis/2009/08/24/troubleshooting-blank-layers/
0 Kudos