AnsweredAssumed Answered

Data References Remain After Calling DeleteLayer

Question asked by bruce.nielsen on Apr 9, 2012
Latest reply on Apr 11, 2012 by bruce.nielsen
I'm working on a button for ArcGIS 9.2 using Visual Studio 2005. The workflow is pretty simple:

  • Add a point shapefile

  • Dim strName As String = "points.shp" Dim pSFactory As IWorkspaceFactory = New ShapefileWorkspaceFactory Dim pWS As IWorkspace = pSFactory.OpenFromFile("F:\data", m_application.hWnd) 'This is a network drive Dim pFWS As IFeatureWorkspace = pWS 'QI Dim pFC As IFeatureClass = pFWS.OpenFeatureClass(strName) Dim pPtLayer As IFeatureLayer = New FeatureLayer pPtLayer.FeatureClass = pFC pPtLayer.Name = "Points" pMxDoc.FocusMap.AddLayer(pPtLayer)

  • Select the points within 1 mile of a polygon layer

  • Write the attributes of those points to a DBF file

  • Remove the point shapefile

  • Dim pDL As IDataLayer2 = pPtLayer 'QI pDL.Disconnect() 'Learned about adding these 2 lines from similar postings in the forums pMxDoc.FocusMap.DeleteLayer(pPtLayer) pMxDoc.UpdateContents() pMxDoc.ActiveView.Refresh()

The button works right if only used once. The problem is that even though the points layer is removed from the Table of Contents, some link to the data remains. Using the delete command in the command window shows that there is still some attachment to the points:
If this process doesn't identify any points the first time it is used, it won't for any subsequent runs with different polygon layers, even if some of the points qualify.

Is there any way to remove all references to the points layer that the process is using?