<?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 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/an-item-with-the-same-key-has-already-been-added/m-p/545558#M6689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using 100.5 version of Esri RunTime&amp;nbsp;Sdk for WPF/C#.&lt;/P&gt;&lt;P&gt;I would like to add Graphic objects into&amp;nbsp;GraphicsOverlay, but i don't like to initialize Graphic class into loop.I initialize&amp;nbsp; Graphic class outside loop and appear next error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An item with the same key has already been added.&lt;BR /&gt; at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)&lt;BR /&gt; at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)&lt;BR /&gt; at Esri.ArcGISRuntime.Internal.AttributeDictionary.Add(String key, Object value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solved this problem, because i have a lot of Graphics and i like to work my application fast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Aug 2019 11:49:09 GMT</pubDate>
    <dc:creator>KiroAndreev1</dc:creator>
    <dc:date>2019-08-06T11:49:09Z</dc:date>
    <item>
      <title>An item with the same key has already been added</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/an-item-with-the-same-key-has-already-been-added/m-p/545558#M6689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using 100.5 version of Esri RunTime&amp;nbsp;Sdk for WPF/C#.&lt;/P&gt;&lt;P&gt;I would like to add Graphic objects into&amp;nbsp;GraphicsOverlay, but i don't like to initialize Graphic class into loop.I initialize&amp;nbsp; Graphic class outside loop and appear next error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An item with the same key has already been added.&lt;BR /&gt; at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)&lt;BR /&gt; at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)&lt;BR /&gt; at Esri.ArcGISRuntime.Internal.AttributeDictionary.Add(String key, Object value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solved this problem, because i have a lot of Graphics and i like to work my application fast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2019 11:49:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/an-item-with-the-same-key-has-already-been-added/m-p/545558#M6689</guid>
      <dc:creator>KiroAndreev1</dc:creator>
      <dc:date>2019-08-06T11:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: An item with the same key has already been added</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/an-item-with-the-same-key-has-already-been-added/m-p/545559#M6690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiro, Refer the attached code for a sample example and see if it works. Also, post your code so that we could try to resolve it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:30:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/an-item-with-the-same-key-has-already-been-added/m-p/545559#M6690</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-08-06T12:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: An item with the same key has already been added</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/an-item-with-the-same-key-has-already-been-added/m-p/545560#M6691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public void ReadBuildingsGML()&lt;BR /&gt; {&lt;BR /&gt; try&lt;BR /&gt; {&lt;BR /&gt; String graphGraphBuild = null;&lt;BR /&gt; string tempPath = Path.Combine(Path.GetTempPath(), "Temp");&lt;BR /&gt; //Set Folder permission&lt;BR /&gt; FullPermissions fullPermissions = new FullPermissions(tempPath);&lt;BR /&gt; fullPermissions.SetFullAccessPermissionsForEveryone();&lt;BR /&gt; XmlDocument docGrap = new XmlDocument();&lt;BR /&gt; Dictionary&amp;lt;String, Object&amp;gt; graphAttrBuild = new Dictionary&amp;lt;string, Object&amp;gt;();&lt;BR /&gt; if (File.Exists(tempPath + @"\" + graphKO + ".gml"))&lt;BR /&gt; {&lt;BR /&gt; XmlDocument doc = new XmlDocument();&lt;BR /&gt; doc.Load(tempPath + @"\" + graphKO + ".gml");&lt;BR /&gt; var nsManager = new XmlNamespaceManager(new NameTable());&lt;BR /&gt; //register mapping of prefix to namespace uri &lt;BR /&gt; nsManager.AddNamespace("gml", "http://www.opengis.net/gml");&lt;BR /&gt; XmlNodeList xnList = doc.SelectNodes("//gml:featureMember", nsManager);&lt;BR /&gt; for (int i = 0; i &amp;lt; xnList.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; XmlNode nodeChild = xnList&lt;I&gt;.FirstChild;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;for (int j = 0; j &amp;lt; nodeChild.ChildNodes.Count; j++)&lt;BR /&gt; {&lt;BR /&gt; string[] firstSubStr = nodeChild.ChildNodes&lt;J&gt;.Name.Split(delimRead);&lt;BR /&gt; if (firstSubStr[0] == "akn" || firstSubStr[0] == "arec")&lt;BR /&gt; {&lt;BR /&gt; int index = nodeChild.ChildNodes&lt;J&gt;.Name.IndexOf(":") + 1;&lt;BR /&gt; string name = nodeChild.ChildNodes&lt;J&gt;.Name.Substring(index);&lt;BR /&gt; if (name != "GEOMETRY")&lt;BR /&gt; {&lt;BR /&gt; if (name == "BUILDNO")&lt;BR /&gt; {&lt;BR /&gt; GetSetBuildNumber.Number = nodeChild.ChildNodes&lt;J&gt;.InnerText;&lt;BR /&gt; }&lt;BR /&gt; if (name == "PARCNO")&lt;BR /&gt; {&lt;BR /&gt; GetSetParcNumber.Number = nodeChild.ChildNodes&lt;J&gt;.InnerText;&lt;BR /&gt; }&lt;BR /&gt; if (name == "MAIN_PARCEL")&lt;BR /&gt; {&lt;BR /&gt; GetSetMainParc.MainParc = nodeChild.ChildNodes&lt;J&gt;.InnerText;&lt;BR /&gt; }&lt;BR /&gt; graphAttrBuild.Add(name, nodeChild.ChildNodes&lt;J&gt;.InnerText);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; graphGraphBuild = "&amp;lt;xml&amp;gt;" + nodeChild.ChildNodes&lt;J&gt;.InnerXml + "&amp;lt;/xml&amp;gt;";&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; docGrap.LoadXml(graphGraphBuild);&lt;BR /&gt; XmlNodeList polygonList = docGrap.SelectNodes("//gml:Polygon", nsManager);&lt;BR /&gt; XmlNodeList outerBoundaryIs = docGrap.SelectNodes("//gml:outerBoundaryIs", nsManager);&lt;BR /&gt; if (polygonList[0].ChildNodes.Count &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; Polygon polygonOB = jsonParser.CreatePolygon(outerBoundaryIs[0].ChildNodes.Item(0).InnerText);&lt;BR /&gt; for (int k = 1; k &amp;lt; polygonList[0].ChildNodes.Count; k++)&lt;BR /&gt; {&lt;BR /&gt; if (polygonList[0].ChildNodes.Item(k).InnerText.Trim() != string.Empty)&lt;BR /&gt; {&lt;BR /&gt; if (FlagOrig == "NBO")&lt;BR /&gt; {&lt;BR /&gt; String param = graphAttrBuild["BUILDNO"].ToString() + "," + graphAttrBuild["PARCNO"].ToString();&lt;BR /&gt; String coordParam = jsonParser.RoundDeimal(polygonList.Item(0).ChildNodes&lt;K&gt;.InnerText) + "\t" + param;&lt;BR /&gt; GlobalVar.InnerBoundBuildList.Add(coordParam);&lt;BR /&gt; }&lt;BR /&gt; polygonOB = GeometryEngine.Difference(polygonOB, jsonParser.CreatePolygon(polygonList.Item(0).ChildNodes&lt;K&gt;.InnerText)) as Polygon;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; Graphic graphic_Label = new Graphic();&lt;BR /&gt; Graphic graphic = new Graphic();&lt;BR /&gt; graphic.Geometry = polygonOB;&lt;BR /&gt; foreach (var attr1 in graphAttrBuild)&lt;BR /&gt; {&lt;BR /&gt; if (attr1.Key == "BUILDNO")&lt;BR /&gt; GetSetBuildNumber.Number = attr1.Value.ToString();&lt;BR /&gt; if (attr1.Key == "MAIN_PARCEL")&lt;BR /&gt; GetSetMainParc.MainParc = attr1.Value.ToString();&lt;BR /&gt; graphic.Attributes.Add(attr1.Key, attr1.Value);&lt;BR /&gt; }&lt;BR /&gt; if (FlagOrig == "NBO")&lt;BR /&gt; graphic.Symbol = styleObject.SetBuildSymbol(GetSetMainParc.MainParc);&lt;BR /&gt; if (FlagOrig == "BO")&lt;BR /&gt; graphic.Symbol = styleObject.SetOriginal();&lt;BR /&gt; MapPoint label = GeometryEngine.LabelPoint(polygonOB);&lt;BR /&gt; graphic_Label.Geometry = label;&lt;BR /&gt; graphic_Label.Symbol = Symbol.FromJson(styleObject.SymbolKO_Build_ToJson(Color.Black, 10, Color.Yellow, GetSetBuildNumber.Number, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Bottom, 3));&lt;BR /&gt; Parallel.Invoke(&lt;BR /&gt; () =&amp;gt; _overlay_Graphic.Graphics.Add(graphic),&lt;BR /&gt; () =&amp;gt; _overlay_Graphic_Label.Graphics.Add(graphic_Label));&lt;BR /&gt; graphAttrBuild.Clear();&lt;BR /&gt; GlobalVar.ListBuildNo.Add(GetSetParcNumber.Number + ";" + GetSetBuildNumber.Number);&lt;BR /&gt; GlobalVar.UidKO.Add(i + 1);&lt;BR /&gt; GlobalVar.StartCount = i + 1;&lt;BR /&gt; // graphic = null;&lt;BR /&gt; graphic_Label = null;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; catch&lt;BR /&gt; (Exception ex)&lt;BR /&gt; { logger.Error(ex, "Настана грешка."); MessageBox.Show("Настана грешка. Ве молиме проверете логови (во /logs фолдерот) и контактирајте го администраторот."); }&lt;BR /&gt; }&lt;/K&gt;&lt;/K&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function read gml file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2019 13:50:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/an-item-with-the-same-key-has-already-been-added/m-p/545560#M6691</guid>
      <dc:creator>KiroAndreev1</dc:creator>
      <dc:date>2019-08-06T13:50:57Z</dc:date>
    </item>
  </channel>
</rss>

