Data References Remain After Calling DeleteLayer

294
2
Jump to solution
04-09-2012 05:41 AM
Highlighted
Regular Contributor
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:
[ATTACH=CONFIG]13337[/ATTACH]
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?
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Regular Contributor
I asked the same question on another forum, and received this suggestion which removed the extra references to the removed layer
Dim pGPU As IGPUtilities2 = New GPUtilities pGPU.RemoveInternalLayer(pTELayer.Name)

View solution in original post

0 Kudos
2 Replies
Highlighted
MVP Honored Contributor
Have you also released all the variable references to the file? Take a look at this 9.2 help page on some of the different options.
0 Kudos
Highlighted
Regular Contributor
I asked the same question on another forum, and received this suggestion which removed the extra references to the removed layer
Dim pGPU As IGPUtilities2 = New GPUtilities pGPU.RemoveInternalLayer(pTELayer.Name)

View solution in original post

0 Kudos