I have a polygon layer (pLayer) in a project that is created with a Definition Query to a FeatureClass within a FeatureDataset in a Personal Geodatabase (.mdb). I am trying to use ArcObjects (9.2, Visual Studio 2005) to create a 1 mile buffer around the features in the layer. I'm having a problem with the following code: '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
If the code is run as you see it now, it cycles through all of the features in the source featureclass, not just those defined by the definition query. If I try to use the definition query as a query filter (uncomment the 3 lines of code and change the search parameter from Nothing to pQF), it errors out on the Search with the messageA first chance exception of type 'System.Runtime.InteropServices.COMException' occurred...
Any hints would be appreciated.