<?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 Re: Object is already owned, C# in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495086#M12801</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You have situation similar like in &lt;A href="https://community.esri.com/t5/net-maps-sdk-questions/add-two-layers-to-mapview-control-from-same/m-p/1479826#M12737" target="_self"&gt;thread&lt;/A&gt;. I think&amp;nbsp;&lt;SPAN&gt;BlockGroupGeoPackage.GeoPackageFeatureTables[0] makes a bomb. You need to create object from scratch, because Maps SDK saves somewhere your used objects.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jun 2024 20:05:39 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2024-06-19T20:05:39Z</dc:date>
    <item>
      <title>Object is already owned, C#</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495005#M12800</link>
      <description>&lt;P&gt;Running into 2 related issues&lt;/P&gt;&lt;P&gt;I have a map the users interact with, it uses an Operational Layer and a graphics overlay collection&lt;/P&gt;&lt;P&gt;Now my issue&lt;/P&gt;&lt;P&gt;If the user closes the map, and then comes back into the map, I run into this error.&lt;/P&gt;&lt;P&gt;For Graphics overlays I have been trying to clear() both the graphics layer on the map and clear() the graphics collection&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;EsriMapView.GraphicsOverlays.Clear();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;BasicOverlays.Clear();&amp;nbsp; GraphicCollection&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We do A WHOLE lot of stuff, and then I bomb here.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;EsriMapView.GraphicsOverlays = BasicOverlays;// this is bombing on re enter&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The operational layer is a little more tricky, and does NOT bomb whenever I come back in. But wont allow me to change the data or redraw the data, like if the user selects a different file to load, or changes a rendering option.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;//Are we entering this again?&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;if (SectorLayer != null)&amp;nbsp; Not firing on reenter, but does if I try and call this method again to "redraw"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;EsriMapView.Map.OperationalLayers.Remove(SectorLayer); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;SectorLayer = null; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;try&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;SectorLayer = new Esri.ArcGISRuntime.Mapping.FeatureLayer(BlockGroupGeoPackage.GeoPackageFeatureTables[0]); &amp;lt;- Bombs here&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;catch&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;MessageBox.Show("Error Adding Sector Outlines");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;SectorLayer.Renderer = _alternateRenderer;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;EsriMapView.Map.OperationalLayers.Add(SectorLayer);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both are showing the same error, could someone help me out here understanding this? According the debug the layers are clear, the SectorLayer is Null, the graphics layers &amp;amp; collection are clear, and the map.operational layer is clear.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 17:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495005#M12800</guid>
      <dc:creator>SP2501</dc:creator>
      <dc:date>2024-06-19T17:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Object is already owned, C#</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495086#M12801</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You have situation similar like in &lt;A href="https://community.esri.com/t5/net-maps-sdk-questions/add-two-layers-to-mapview-control-from-same/m-p/1479826#M12737" target="_self"&gt;thread&lt;/A&gt;. I think&amp;nbsp;&lt;SPAN&gt;BlockGroupGeoPackage.GeoPackageFeatureTables[0] makes a bomb. You need to create object from scratch, because Maps SDK saves somewhere your used objects.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 20:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495086#M12801</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-06-19T20:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Object is already owned, C#</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495365#M12809</link>
      <description>&lt;P&gt;GK, thanks for the input! Thread helped.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 14:00:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495365#M12809</guid>
      <dc:creator>SP2501</dc:creator>
      <dc:date>2024-06-20T14:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Object is already owned, C#</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495520#M12814</link>
      <description>&lt;P&gt;A Map or a GraphicsOverlay can only be attached to a single MapView instance. So when you reuse those objects, make sure they are unhooked from the old mapview.&lt;/P&gt;&lt;P&gt;Now this gets a little tricky because of the garbage collector meaning you don't really know when the MapView is getting collected and unhooked from the map and graphics collection. A couple approaches you can do to make that more deterministic:&lt;BR /&gt;1. Either reuse the same MapView across pages&lt;BR /&gt;2. When navigating away from the mapview page, set the Map and GraphicsOverlays properties to null to unhook them immediately and get them unowned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 17:15:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/object-is-already-owned-c/m-p/1495520#M12814</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2024-06-20T17:15:38Z</dc:date>
    </item>
  </channel>
</rss>

