<?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: System.ArgumentException 'An item with the same key has already been added' in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573730#M7024</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Really I am mostly anxious about a new version of the control. &lt;/SPAN&gt;&lt;EM style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #3d3d3d; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: italic; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; vertical-align: baseline; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;&lt;STRONG style="border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: italic; font-weight: bold; outline-color: invert; outline-style: none; outline-width: 0px; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;It's been 6 months &lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We're generally shipping out 2 releases a year, and the next one is right around the corner. And it's "only" been 4 months since 100.2.1 released &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And we're probably/hopefully/planning to be shipping 3 releases this year...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AFAIK this issue was resolved a while ago. Are you still seeing it with v100.2.1 ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jun 2018 16:38:20 GMT</pubDate>
    <dc:creator>dotMorten_esri</dc:creator>
    <dc:date>2018-06-15T16:38:20Z</dc:date>
    <item>
      <title>System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573724#M7018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I diagnose the above exception? In my code, I roughly do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create an overlay ( &lt;EM&gt;&lt;STRONG&gt;overlay =&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;new GraphicsOverlay()&lt;/STRONG&gt;&lt;/EM&gt; )&lt;/P&gt;&lt;P&gt;2. Create a set of polygons ( &lt;EM&gt;&lt;STRONG&gt;poly =&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;new Polygon(mappoints)&lt;/STRONG&gt;&lt;/EM&gt; where &lt;EM&gt;&lt;STRONG&gt;mappoints&lt;/STRONG&gt;&lt;/EM&gt; is a &lt;EM&gt;&lt;STRONG&gt;PointCollection&lt;/STRONG&gt;&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;3. Create a graphic with the polygon geometry and a simple fill symbol for each polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;( &lt;EM&gt;&lt;STRONG&gt;graphic = new Graphic() { Geometry = poly, Symbol = new SimpleFillSymbol() { Color = Colors.Red&amp;nbsp;} }&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;4. Add that graphic to the overlay. ( &lt;EM&gt;&lt;STRONG&gt;overlay.Add(graphic)&lt;/STRONG&gt;&lt;/EM&gt; )&lt;/P&gt;&lt;P&gt;Then, when something changes, I will call &lt;EM&gt;&lt;STRONG&gt;overlay.Graphics.Clear()&lt;/STRONG&gt;&lt;/EM&gt;, then repeat steps 2-3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I do this, sometimes on the &lt;EM&gt;&lt;STRONG&gt;new Graphic(...)&lt;/STRONG&gt;&lt;/EM&gt;, I will get the exception (but not every time)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using Esri.ArcGISRuntime version 100.0.0.0.&lt;/P&gt;&lt;P&gt;Any idea what's going on?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:07:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573724#M7018</guid>
      <dc:creator>DavidHope</dc:creator>
      <dc:date>2017-01-05T20:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573725#M7019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #242729; background-color: #ffffff; border: 0px; margin: 0px 0px 1em;"&gt;Ok, it appears that the problem was that because the &lt;CODE style="border: 0px; font-size: 13px; padding: 1px 5px;"&gt;overlay.Graphics.Clear()&lt;/CODE&gt; was just releasing the objects to the garbage collector that the underlying native objects hadn't yet been disposed.&lt;/P&gt;&lt;P style="color: #242729; background-color: #ffffff; border: 0px; margin: 0px 0px 1em;"&gt;By forcing the garbage collector to run:&lt;/P&gt;&lt;PRE class="" style="color: #393318; border: 0px; font-size: 13px; margin: 0px 0px 1em; padding: 5px;"&gt;&lt;CODE style="border: 0px; font-size: 13px;"&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GC&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;"&gt;Collect&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"&gt;();&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GC&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;"&gt;WaitForPendingFinalizers&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"&gt;();&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="color: #242729; background-color: #ffffff; border: 0px; margin: 0px 0px 1em;"&gt;This caused the objects to be disposed and eliminates the "same key" exception&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2017 14:42:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573725#M7019</guid>
      <dc:creator>DavidHope</dc:creator>
      <dc:date>2017-01-06T14:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573726#M7020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks David. We are aware of this issue already, and working on a fix. Your workaround is the best known approach for now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2017 21:21:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573726#M7020</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2017-01-06T21:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573727#M7021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any update on this? (or any news on an updated version of the ArcGIS v100.0 ?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are having issues with the workaround mentioned above. Basically WaitForPendingFinalizers is freezing the app... and this is bad practice anyway.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2017 11:22:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573727#M7021</guid>
      <dc:creator>andybeaulieu</dc:creator>
      <dc:date>2017-06-08T11:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573728#M7022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This works for us 99.9% of the time. &amp;nbsp;Every once in a while one of these errors slips through the lines of defense, but they are very rare since we implemented this.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; GC.Collect();&lt;BR /&gt; GC.WaitForPendingFinalizers();&lt;BR /&gt; GC.Collect();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2017 13:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573728#M7022</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2017-06-08T13:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573729#M7023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In our case, the WaitForPendingFinalizers() call was freezing the whole app in some situations. Probably something unique to a particular situation and what the garbage collector had to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Really I am mostly anxious about a new version of the control. &lt;EM&gt;&lt;STRONG&gt;It's been 6 months &lt;/STRONG&gt;&lt;/EM&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if anyone else hits this specific issue, this is the general workaround that we used instead of GC.Collect.. Basically just kept a list of Graphics and instead of Clear()'ing them, we re-use...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;first keep a cache of Graphics.&lt;BR /&gt; private List&amp;lt;Graphic&amp;gt; RouteGraphics { get; set; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{...}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// later on when creating geometries... Re-use items from the Cache&lt;/P&gt;&lt;P&gt;// so you don't&amp;nbsp;need to Clear()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Polyline newPolyLine = new Polyline(mapPoints);&lt;BR /&gt; if (RouteGraphics.Count &amp;gt; routeGraphicIndex)&lt;BR /&gt; {&lt;BR /&gt; // we will re-use an existing Route Graphic&lt;BR /&gt; Graphic routeGraphicExisting = RouteGraphics[routeGraphicIndex];&lt;BR /&gt; routeGraphicExisting.Geometry = newPolyLine;&lt;BR /&gt; routeGraphicExisting.IsVisible = true;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; // we will create a new Route Graphic&lt;BR /&gt; SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, lineColor, 3.0);&lt;BR /&gt; Graphic routeGraphicNew = new Graphic(newPolyLine, lineSymbol);&lt;BR /&gt; //System.Diagnostics.Debug.WriteLine(" Adding routeGraphicNew");&lt;BR /&gt; MapOverlay.Graphics.Add(routeGraphicNew);&lt;BR /&gt; RouteGraphics.Add(routeGraphicNew);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;routeGraphicIndex++;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2017 17:49:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573729#M7023</guid>
      <dc:creator>andybeaulieu</dc:creator>
      <dc:date>2017-06-08T17:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: System.ArgumentException 'An item with the same key has already been added'</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573730#M7024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Really I am mostly anxious about a new version of the control. &lt;/SPAN&gt;&lt;EM style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #3d3d3d; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: italic; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; vertical-align: baseline; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;&lt;STRONG style="border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: italic; font-weight: bold; outline-color: invert; outline-style: none; outline-width: 0px; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;It's been 6 months &lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We're generally shipping out 2 releases a year, and the next one is right around the corner. And it's "only" been 4 months since 100.2.1 released &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And we're probably/hopefully/planning to be shipping 3 releases this year...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AFAIK this issue was resolved a while ago. Are you still seeing it with v100.2.1 ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2018 16:38:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/system-argumentexception-an-item-with-the-same-key/m-p/573730#M7024</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2018-06-15T16:38:20Z</dc:date>
    </item>
  </channel>
</rss>

