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.
User contributions licensed under CC BY-SA 3.0