I have a bunch of users running a 10.2.1 VB.Net extension, which assumes they have a particular MXD loaded. That MXD contains an existing ArcGIS Server layer (ie. not added programmatically by the extension):

layer Properties

I can get an ILayer reference to that layer using IMap.Layer([idx]), but the returned COM object does not seem to support any other interface. Casting it to IMapServerLayer, IMapServerGroupLayer, IMapServerSubLayer etc all return Nothing.

What interfaces should this object support, and how do I get a more useful object than ILayer out of it? (eg. to be able to perform spatial queries on it?)

Edit: I had a crack at this sample:

Dim uidMapServerLayer As New ESRI.ArcGIS.esriSystem.UID()
uidMapServerLayer.Value = "{E9B56157-7EB7-4DB3-9958-AFBF3B5E1470}" ' IMapServerLayer GUID

Dim enLayers As IEnumLayer = pMap.Layers(uidMapServerLayer, True)
Dim eLayer As ILayer = enLayers.Next
While Not eLayer Is Nothing
    Dim eMSLLayer As IMapServerLayer = eLayer
    eLayer = enLayers.Next          ' <-- breakpoint here
End While

...and eMSLLayer is a valid object. But if I break it at the breakpoint line and execute CType(eLayer, IMapServerLayer) I get Cannot convert to 'Interface IMapServerLayer'...(this was what I was using to test if the ILayer object supported the various interfaces, so apparently I'm barking up the wrong tree)

  • Try casting to a IMapServerGroupLayer first and if you can pull the sub-layers from there. resources.arcgis.com/en/help/arcobjects-net/componenthelp/… – Eok Sep 1 '15 at 17:26
  • Nope - doesn't support that one either. I've tried pretty much every I[something]Layer interface I can find, and the only interface I can find that it supports is ILayer. – Juffy Sep 8 '15 at 1:45
  • See edit....I think I'm driving myself nuts. :( – Juffy Sep 8 '15 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.