0

My goal is to connect to a WMS Service and display a layer on my application's map using ESRI's ArcObject API for .NET.

Here is the part of my code I am struggling with:

...

String url = "some value";
String layerTitle = "another value";

...

PropertySet props = new PropertySet();
props.SetProperty("URL", url);

WMSConnectionName connectionName = new WMSConnectionName();
connectionName.ConnectionProperties = props;

WMSMapLayer mapLayer = new WMSMapLayer();
(mapLayer as IDataLayer).Connect(connectionName as IName);

IWMSGroupLayer groupLayer = (IWMSGroupLayer)mapLayer;
IWMSServiceDescription serviceDescription = groupLayer.WMSServiceDescription;
IWMSLayerDescription layerDescription = serviceDescription.get_LayerDescription(0);

groupLayer.CreateWMSLayer(layerDescription);
groupLayer.get_Layer(0).Visible = true;

ILayer layer = (ILayer)groupLayer;
layer.Name = "WxOverlays " + layerTitle;
layer.Visible = true;

At run time I encounter:

System.Runtime.InteropServices.COMException (0x8000FFFF): The supplied command does not exist in the command pool at ESRI.ArcGIS.GISClient.IWMSServiceDescription.get_LayerDescription(Int32 index)

A google search revealed that some similar methods in the ArcObject API throw the same exception because they are not supported in C#. Has anyone encountered this before? Anyone see a way around it? Unfortunately, I am stuck using C#, so using Java or something that may have better support from ESRI is out of the question.

ylka
  • 293
  • 8
  • 14
Zane
  • 1
  • 1
    Seems like it's a 400000th C# question. You should get a prize! :) – Filip Skakun Jan 09 '13 at 22:34
  • I wonder if that means C# is really popular, or just really hard to understand? :) Anyway, back to the question - I don't think your problem is that get_LayerDescription isn't supported, or else there wouldn't be a C# example in the API docs. Have you tried calling .LayerDescriptionCount to see if there's any valid WMS layers? – Juffy Jan 10 '13 at 01:01

0 Answers0