I have this method in my code and have a button that when clicked run this code. In the first click all of code runs without error. but in second run i rcieved this error on line:IFeatureCursor fcDistrict = flDistrict.Search(null, false); "Exception from HRESULT: 0x8005018B"
Void function(){ IFeatureLayer flCircuit = ClsGeneral.FindLayer(ClsShares.FC_CIRCUIT); IFeatureLayer flSubstat = ClsGeneral.FindLayer(ClsShares.FC_SUBSTAT); IFeatureLayer flLoad_center = ClsGeneral.FindLayer(ClsShares.FC_LOAD_CENTER); IFeatureLayer flDistrict = ClsGeneral.FindLayer(ClsShares.FC_DISTRICT); IFeatureCursor fcDistrict = flDistrict.Search(null, false); IFeature fDistrict = fcDistrict.NextFeature(); ISpatialFilter sf = new SpatialFilterClass(); while (fDistrict != null) { int indCFCapacity = fDistrict.Fields.FindField("HIGHDIST_CIRCUIT_FREE_CAPACITY"); int indHSFCapacity = fDistrict.Fields.FindField("HIGHDIST_SUBSTAT_FREE_CAPACITY"); int indTSFCapacity = fDistrict.Fields.FindField("TRANSFER_SUBSTAT_FREE_CAPACITY"); fDistrict.set_Value(indCFCapacity, 0); fDistrict.set_Value(indHSFCapacity, 0); fDistrict.set_Value(indTSFCapacity, 0); sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; sf.Geometry = fDistrict.Shape; sf.GeometryField = flDistrict.FeatureClass.ShapeFieldName; IFeatureCursor fcCircuit = flCircuit.Search(sf, true); IFeature fCircuit = fcCircuit.NextFeature(); while (fCircuit != null) { int indVol = fCircuit.Fields.FindField("UTNOM_VOLT"); int indFCCapacity = fCircuit.Fields.FindField("FREE_CAPACITY"); int Vol; int.TryParse(fCircuit.get_Value(indVol).ToString(), out Vol); if (Vol < 132) { double oldValue; double.TryParse(fDistrict.get_Value(indCFCapacity).ToString(), out oldValue); double sumValue; double.TryParse(fCircuit.get_Value(indFCCapacity).ToString(), out sumValue); fDistrict.set_Value(indCFCapacity, oldValue + sumValue); } fCircuit = fcCircuit.NextFeature(); } } }}
أكثر...
Void function(){ IFeatureLayer flCircuit = ClsGeneral.FindLayer(ClsShares.FC_CIRCUIT); IFeatureLayer flSubstat = ClsGeneral.FindLayer(ClsShares.FC_SUBSTAT); IFeatureLayer flLoad_center = ClsGeneral.FindLayer(ClsShares.FC_LOAD_CENTER); IFeatureLayer flDistrict = ClsGeneral.FindLayer(ClsShares.FC_DISTRICT); IFeatureCursor fcDistrict = flDistrict.Search(null, false); IFeature fDistrict = fcDistrict.NextFeature(); ISpatialFilter sf = new SpatialFilterClass(); while (fDistrict != null) { int indCFCapacity = fDistrict.Fields.FindField("HIGHDIST_CIRCUIT_FREE_CAPACITY"); int indHSFCapacity = fDistrict.Fields.FindField("HIGHDIST_SUBSTAT_FREE_CAPACITY"); int indTSFCapacity = fDistrict.Fields.FindField("TRANSFER_SUBSTAT_FREE_CAPACITY"); fDistrict.set_Value(indCFCapacity, 0); fDistrict.set_Value(indHSFCapacity, 0); fDistrict.set_Value(indTSFCapacity, 0); sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; sf.Geometry = fDistrict.Shape; sf.GeometryField = flDistrict.FeatureClass.ShapeFieldName; IFeatureCursor fcCircuit = flCircuit.Search(sf, true); IFeature fCircuit = fcCircuit.NextFeature(); while (fCircuit != null) { int indVol = fCircuit.Fields.FindField("UTNOM_VOLT"); int indFCCapacity = fCircuit.Fields.FindField("FREE_CAPACITY"); int Vol; int.TryParse(fCircuit.get_Value(indVol).ToString(), out Vol); if (Vol < 132) { double oldValue; double.TryParse(fDistrict.get_Value(indCFCapacity).ToString(), out oldValue); double sumValue; double.TryParse(fCircuit.get_Value(indFCCapacity).ToString(), out sumValue); fDistrict.set_Value(indCFCapacity, oldValue + sumValue); } fCircuit = fcCircuit.NextFeature(); } } }}
أكثر...