|
[ArgumentException: an item with the same key has already been added] System.throwHelper.throwArgumentException(ExceptionResource resource) +51 System.Collections.Generic.Dictionary'2.Insert(Tkey Key,Tvalue value,Boolean add) +7462172 System.Web.Query.Dynamic.ClassFactory.GetDynamicClass(IEnumerable '1 properties) +122 System.Web.Query.Dynamic.ExpressionParser.ParseNew() +406 System.Web.Query.Dynamic.ExpressionParser.ParseIdentifier() +230 System.Web.Query.Dynamic.ExpressionParser.ParsePrimaryStart() +34 System.Web.Query.Dynamic.ExpressionParser.ParsePrimary() +13 System.Web.Query.Dynamic.ExpressionParser.ParseUnary() +259 Above written lines are the errors coming in my project. These errors are coming very rearly. If anyone have the solution i shall be very thankful. Please reply. | | Dheer_brain Wednesday, July 08, 2009 12:10 PM | You're using a dictionary and you're trying to add an item with same key. Check code, avoid that. Dictionary.add("key1","item1") Dictionary.add("key2","item2") Dictionary.add("key1","item3") << not allowed. Check what part of your code is causing that.
Thanks - Omie Someone makes my heart skip a clock cycle !- Marked As Answer byAland LiMSFT, ModeratorTuesday, July 14, 2009 2:32 AM
- Edited byOmie Wednesday, July 08, 2009 12:44 PM
- Edited byOmie Wednesday, July 08, 2009 12:44 PM
-
| | Omie Wednesday, July 08, 2009 12:42 PM | Hi Dheer_brain,
From my experience, the root cause is that you add an item whose key is already contained in the dictionary.
If you want to allow the later item override the former item, please follow this: "key"] = "value";Otherwise, please follow this:(dic.ContainsKey("key") == false) dic.Add("key", "value");
Let me know if this helps. Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. - Marked As Answer byAland LiMSFT, ModeratorTuesday, July 14, 2009 12:36 PM
-
| | Aland Li Friday, July 10, 2009 3:47 PM | You're using a dictionary and you're trying to add an item with same key. Check code, avoid that. Dictionary.add("key1","item1") Dictionary.add("key2","item2") Dictionary.add("key1","item3") << not allowed. Check what part of your code is causing that.
Thanks - Omie Someone makes my heart skip a clock cycle !- Marked As Answer byAland LiMSFT, ModeratorTuesday, July 14, 2009 2:32 AM
- Edited byOmie Wednesday, July 08, 2009 12:44 PM
- Edited byOmie Wednesday, July 08, 2009 12:44 PM
-
| | Omie Wednesday, July 08, 2009 12:42 PM | Hi Dheer_brain,
From my experience, the root cause is that you add an item whose key is already contained in the dictionary.
If you want to allow the later item override the former item, please follow this: "key"] = "value";Otherwise, please follow this:(dic.ContainsKey("key") == false) dic.Add("key", "value");
Let me know if this helps. Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. - Marked As Answer byAland LiMSFT, ModeratorTuesday, July 14, 2009 12:36 PM
-
| | Aland Li Friday, July 10, 2009 3:47 PM |
|