Quantcast
Channel: Question and Answer » arcmap
Viewing all articles
Browse latest Browse all 248

HRESULT 0×80010202 exception in ArcMap closest feature searching by ArcObjects?

$
0
0

My method must return closest feature attribute. But there’s a problem, it finds closest feature but returns COM exception HRESULT 0×80010202

void selectStreet(IPoint point, IActiveView activeView)
{

..........

if (getLayerByName._GetLayerByName(settings.StreetsLayerName) != null) // Settings1 settings = new Settings1(); settings.StreetsLayerName = "Street"
            {
                var foundLayer = getLayerByName._GetLayerByName(settings.StreetsLayerName);
                IQueryFilterClass qFilter = new IQueryFilterClass () { WhereClause = string.Format("{0} IS NOT NULL", settings.StreetsName) };
                IFeatureCursor featureCursor = (foundLayer as IGeoFeatureLayer).Search(qFilter, false);
                while ((feature = featureCursor.NextFeature()) != null)
                {
                    double distance = ((IProximityOperator)spatialFilter.Geometry).ReturnDistance(feature.Shape);
                    IProximityOperator prox = spatialFilter.Geometry as IProximityOperator;
                    distance = prox.ReturnDistance(feature.Shape);

                    if (closesToId == -1 || distance < closestDistance)
                    {
                        closesToId = feature.OID;
                        closestDistance = distance;
                        resultFeature = feature;
                        var one = feature.get_Value(feature.Fields.FindField(settings.StreetsName)).ToString(); // StreetsName = "STR_NAME"
                        var two = feature.get_Value(feature.Fields.FindField(settings.StreetsStreetCode)).ToString(); //StreetsStreetCode = "STR_CODE"
                    }
                 }
                }
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message); // HRESULT 0x80010202 exception
            }
            return null;
        }
            Where could be a problem?

Viewing all articles
Browse latest Browse all 248

Trending Articles