Hi,
I am facing lots of issues about this bug.
‘The FeatureSource is not open. Please call the Open method before calling this method.’
Whenever using any feature source methods, i am making layer open and also feature source open.
Even though, some of the times it’s raising this bug. I debug it clearly, in some of the times if we execute layer.featuresource.open() method then layer is opened but feature source is not opened. i think that’s why only it’s raising this bug.
I am not sure when it’s happening because if we check one more time on that time, layer and feature source both are opened by calling open method.
Can you clearly explain me, How to handle this bug.
Mostly i am using InMemoryFeatureLayer and ShapeFileFeatureLayer feature source methods.
Code:
1.
ShapeFileFeatureLayer _shpATSPoints = new ShapeFileFeatureLayer(“path\Shape.shp”);
if (!_shpATSPoints.IsOpen)
_shpATSPoints.Open();
_shpATSPoints.FeatureSource.Open();
List features = _shpATSPoints.FeatureSource.SpatialQuery().ToList();
_shpATSPoints.FeatureSource.Close();
_shpATSPoints.Close();
2.
InMemoryFeatureLayer imAircraftLayer = (InMemoryFeatureLayer)((LayerOverlay)wfMap.CustomOverlays[“AircraftOverlay”]).Layers[“Layer1”];
if (!imAircraftLayer.IsOpen)
imAircraftLayer.Open();
imAircraftLayer.FeatureSource.Open();
fts_SelectedAircrafts = imAircraftLayer.FeatureSource.GetFeaturesWithinDistanceOf(e.Position, wfMap.MapUnit, DistanceUnit.NauticalMile, _dAircraftMouseClickDistance, ReturningColumnsType.AllColumns).ToList();
imAircraftLayer.FeatureSource.Close();
imAircraftLayer.Close();
Note: is layer needs to lock then only we can use it.
Thanks,
Riyaz