pragmatically check service type

04-14-2015 11:52 PM
New Contributor III

Hi All,

I want to check service type pragmatically and add corresponding service (Dyanamic or Tiled) on map. If i tried to add globe service as

"ArcGISDynamicMapServiceLayer"  then  code doesn't reached to Initialized or InitializedFailed event.

See below code for reference..

            <esri:ArcGISDynamicMapServiceLayer ID="StreetMapLayer"                          Initialized="ArcGISDynamicMapServiceLayer_Initialized"



On run time, i am getting below exception and i am not able to catch.

Error: Unhandled Error in Silverlight Application

Code: 4004   

Category: ManagedRuntimeError      

Message: System.NullReferenceException: Object reference not set to an instance of an object.

   at ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.<>c__DisplayClasse.<MapServiceInfoInitialized>b__c() 

Any help would be appreciated.

0 Kudos
1 Reply
Esri Frequent Contributor

Neither ArcGISDynamicMapServiceLayer nor ArcGISTiledMapServiceLayer supports globe server.

So in both cases the layer will fail to initialize.

If you want to check if a service supports dynamic or tiled, you can create an ArcGISTiledMapServiceLayer.

If the initialization is OK, it means that the service is cached with the right SR so using an ArcGISTiledMapServiceLayer is the best choice for performances.

If the initialization fails, we can fallback to create an ArcGISDynamicMapServiceLayer. If the initialization fails, likely the service is not supprted (e.g. globe server) else you can use the ArcGISDynamicMapServiceLayer.

0 Kudos