<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Data References Remain After Calling DeleteLayer in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209446#M5437</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm working on a button for ArcGIS 9.2 using Visual Studio 2005. The workflow is pretty simple:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Add a point shapefile&lt;/LI&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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)&lt;/PRE&gt;&lt;BR /&gt;&lt;LI&gt;Select the points within 1 mile of a polygon layer&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Write the attributes of those points to a DBF file&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Remove the point shapefile&lt;/LI&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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()&lt;/PRE&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]13337[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way to remove all references to the points layer that the process is using?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Apr 2012 12:41:23 GMT</pubDate>
    <dc:creator>BruceNielsen</dc:creator>
    <dc:date>2012-04-09T12:41:23Z</dc:date>
    <item>
      <title>Data References Remain After Calling DeleteLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209446#M5437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm working on a button for ArcGIS 9.2 using Visual Studio 2005. The workflow is pretty simple:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Add a point shapefile&lt;/LI&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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)&lt;/PRE&gt;&lt;BR /&gt;&lt;LI&gt;Select the points within 1 mile of a polygon layer&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Write the attributes of those points to a DBF file&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Remove the point shapefile&lt;/LI&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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()&lt;/PRE&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]13337[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way to remove all references to the points layer that the process is using?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Apr 2012 12:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209446#M5437</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-04-09T12:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Data References Remain After Calling DeleteLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209447#M5438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you also released all the variable references to the file? Take a look at this 9.2 &lt;/SPAN&gt;&lt;A href="http://edndoc.esri.com/arcobjects/9.2/NET/fe9f7423-2100-4c70-8bd6-f4f16d5ce8c0.htm"&gt;help page&lt;/A&gt;&lt;SPAN&gt; on some of the different options.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 13:59:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209447#M5438</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2012-04-10T13:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Data References Remain After Calling DeleteLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209448#M5439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I asked the same question on another forum, and received this suggestion which removed the extra references to the removed layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Dim pGPU As IGPUtilities2 = New GPUtilities pGPU.RemoveInternalLayer(pTELayer.Name)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 16:49:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/data-references-remain-after-calling-deletelayer/m-p/209448#M5439</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-04-11T16:49:50Z</dc:date>
    </item>
  </channel>
</rss>

