What is wrong with this vb.net code?

328
2
08-15-2018 07:56 AM
JoseSanchez
Occasional Contributor III

Hello everyone,

I am working with VS 2015 and ArcGIS 10.4.1.

I am trying to select polygons form a Parcel layer using the folio number and union them to copy the union in another polygon layer.

From this sample:

http://edndoc.esri.com/arcobjects/9.2/NET/11bc37dc-197b-4ddd-bc0d-2b11c4ca7747.htm

I wrote this source code:

 

' Use the WhereClause property to select only those that match tghe criteria

queryFilterPaParcel = New QueryFilterClass()

queryFilterPaParcel.SubFields = "FOLIO"

queryFilterPaParcel.WhereClause = ""

'

' Create list of folios

'

For i = 0 To listFolios.Count - 1

strFolioWhereClause = strFolioWhereClause & "FOLIO = '" & listFolios.Item(i).ToString & "' "

If i < listFolios.Count - 1 Then

strFolioWhereClause = strFolioWhereClause & " AND "

End If

Next

'

' Select Folios in Parcels Layer (psde2.MDC.PaParcel) Database

'

queryFilterPaParcel.WhereClause = strFolioWhereClause

pParcelCursor = pFeatureClassParcel.Search(queryFilterPaParcel, False)

currentFeature = pParcelCursor.NextFeature()

pTopoOp = currentFeature.Shape     

********************************************  IT FAILS HERE  WITH TIS ERRROR MESSAGE:

Error HRESULT E_FAIL has been returned from a call to a COM component.

Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\ESRI.ArcGIS.Geometry\v4.0_10.4.0.0__8fc3cc631e44ad86\ESRI.ArcGIS.Geometry.dll'. Cannot find or open the PDB file.

Exception thrown: 'System.Runtime.InteropServices.COMException' in

************************************************************************************************************************************

If Not (currentFeature Is Nothing) Then

Dim missing As Object = Type.Missing

geometryCollection.AddGeometry(currentFeature.Shape, Nothing, Nothing)

currentFeature = pParcelCursor.NextFeature()

End If

'Create the polygon that will be the union of the features returned from the search cursor.

'The spatial reference of this feature does not need to be set ahead of time. The

'ConstructUnion method defines the constructed polygon's spatial reference to be the same as

'the input geometry bag.

Dim unionedPolygon As ITopologicalOperator = New PolygonClass()

unionedPolygon.ConstructUnion(geometryBag)

Dim outPoly As IPolygon = CType(unionedPolygon, IPolygon)

0 Kudos
2 Replies
JoseSanchez
Occasional Contributor III

It works when I select the whole Feature class in the Search:

pParcelCursor = pFeatureClassParcel.Search(Nothing, False)

but it fails:

' pParcelCursor = pFeatureClassParcel.Search(queryFilterPaParcel, False)

Any idea why?

0 Kudos
JoseSanchez
Occasional Contributor III

Found it.

queryFilterPaParcel.SubFields = "*"   instread of queryFilterPaParcel.SubFields = "FOLIO"

0 Kudos