'Create a union-ed geometry of all of the features in the layer Dim pFL2 As IFeatureLayer2 = pLayer Dim pFClass As IFeatureClass = pFL2.FeatureClass 'Dim pFLD As IFeatureLayerDefinition = pFL2 'Dim pQF As IQueryFilter = New QueryFilter 'pQF.WhereClause = pFLD.DefinitionExpression Dim pFCursor As IFeatureCursor = pFClass.Search(Nothing, True) 'Replace Nothing with pQF Dim pFeature As IFeature = pFCursor.NextFeature Dim pBag As IGeometryCollection = New GeometryBag Do Until pFeature Is Nothing pBag.AddGeometry(pFeature.Shape, , 0) pFeature = pFCursor.NextFeature Loop
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred...
Solved! Go to Solution.
This Search method will not work on joined fields. If the FeatureLayer has any joins, you should use the IGeoFeatureLayer::SearchDisplayFeatures method instead.
Dim pGFL As IGeoFeatureLayer = pLayer Dim pFCursor As IFeatureCursor = pGFL.SearchDisplayFeatures(Nothing, True)
Dim pFL2 As IFeatureLayer2 = pLayer Dim pFCursor As IFeatureCursor = pFL2.Search(Nothing, True) Dim pFeature As IFeature = pFCursor.NextFeature Dim pBag As IGeometryCollection = New GeometryBag Do Until pFeature Is Nothing pBag.AddGeometry(pFeature.Shape, , 0) pFeature = pFCursor.NextFeature Loop
This Search method will not work on joined fields. If the FeatureLayer has any joins, you should use the IGeoFeatureLayer::SearchDisplayFeatures method instead.
Dim pGFL As IGeoFeatureLayer = pLayer Dim pFCursor As IFeatureCursor = pGFL.SearchDisplayFeatures(Nothing, True)