System.ArgumentException: An entry with the same key already exists.http://forums.asp.net/t/1709724.aspx/1?System+ArgumentException+An+entry+with+the+same+key+already+exists+Tue, 16 Aug 2011 06:13:59 -040017097244550164http://forums.asp.net/p/1709724/4550164.aspx/1?System+ArgumentException+An+entry+with+the+same+key+already+exists+System.ArgumentException: An entry with the same key already exists. <p>Hello to all. I'm &nbsp;a newbie and I joined because I have an error that I just couldn't solve. It's System.ArgumentException: An entry with the same key already exists. error.</p> <p>Here is the whole stack trace:</p> <p><strong>An entry with the same key already exists. </strong><br> <strong>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </strong><br> <br> <strong>Exception Details: System.ArgumentException: An entry with the same key already exists.</strong><br> <br> <strong>Source Error: </strong><br> <strong>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. </strong><br> <br> <br> <strong>Stack Trace: </strong><br> <br> <strong>[ArgumentException: An entry with the same key already exists.]</strong><br> <strong>System.Collections.Specialized.ListDictionary.Add(Object key, Object value) &#43;6157735</strong><br> <strong>System.Collections.Specialized.HybridDictionary.Add(Object key, Object value) &#43;60</strong><br> <strong>System.Web.UI.StateBag.Add(String key, Object value) &#43;126</strong><br> <strong>System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) &#43;77</strong><br> <strong>System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) &#43;113</strong><br> <strong>System.Web.UI.WebControls.SqlDataSource.LoadCompleteEventHandler(Object sender, EventArgs e) &#43;46</strong><br> <strong>System.EventHandler.Invoke(Object sender, EventArgs e) &#43;0</strong><br> <strong>System.Web.UI.Page.OnLoadComplete(EventArgs e) &#43;8876398</strong><br> <strong>System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) &#43;2350</strong></p> <p></p> <p>I can't figure out what produces the error because it shows only frequently. For example: I am browsing my website and refreshing the page over and over and it' s ok for like 10 minutes and then all of a sudden it throws an error. then I refresh it once more and the error is gone.</p> <p>I just don't know when will it show and why, but after refreshing website only once it works perfect again.</p> <p></p> <p>Please help me because I'm starting to freak out.</p> <p>Thanks in advance,</p> <p>marchetto271<br> <br> <br> &nbsp;</p> 2011-08-11T15:33:34-04:004550250http://forums.asp.net/p/1709724/4550250.aspx/1?Re+System+ArgumentException+An+entry+with+the+same+key+already+exists+Re: System.ArgumentException: An entry with the same key already exists. <p></p> <blockquote><span class="icon-blockquote"></span> <h4>marchetto271</h4> <p></p> <p>Hello to all. I'm &nbsp;a newbie and I joined because I have an error that I just couldn't solve. It's System.ArgumentException: An entry with the same key already exists. error.</p> <p>Here is the whole stack trace:</p> <p><strong>An entry with the same key already exists. </strong><br> <strong>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </strong><br> <br> <strong>Exception Details: System.ArgumentException: An entry with the same key already exists.</strong><br> <br> <strong>Source Error: </strong><br> <strong>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. </strong><br> <br> <br> <strong>Stack Trace: </strong><br> <br> <strong>[ArgumentException: An entry with the same key already exists.]</strong><br> <strong>System.Collections.Specialized.ListDictionary.Add(Object key, Object value) &#43;6157735</strong><br> <strong>System.Collections.Specialized.HybridDictionary.Add(Object key, Object value) &#43;60</strong><br> <strong>System.Web.UI.StateBag.Add(String key, Object value) &#43;126</strong><br> <strong>System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) &#43;77</strong><br> <strong>System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) &#43;113</strong><br> <strong>System.Web.UI.WebControls.SqlDataSource.LoadCompleteEventHandler(Object sender, EventArgs e) &#43;46</strong><br> <strong>System.EventHandler.Invoke(Object sender, EventArgs e) &#43;0</strong><br> <strong>System.Web.UI.Page.OnLoadComplete(EventArgs e) &#43;8876398</strong><br> <strong>System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) &#43;2350</strong></p> <p></p> <p>I can't figure out what produces the error because it shows only frequently. For example: I am browsing my website and refreshing the page over and over and it' s ok for like 10 minutes and then all of a sudden it throws an error. then I refresh it once more and the error is gone.</p> <p>I just don't know when will it show and why, but after refreshing website only once it works perfect again.</p> <p></p> <p>Please help me because I'm starting to freak out.</p> <p>Thanks in advance,</p> <p>marchetto271<br> <br> <br> &nbsp;</p> <p></p> </blockquote> <p></p> 2011-08-11T16:39:41-04:004552101http://forums.asp.net/p/1709724/4552101.aspx/1?Re+System+ArgumentException+An+entry+with+the+same+key+already+exists+Re: System.ArgumentException: An entry with the same key already exists. <p>find in your code the the class instance of <strong>'ListDictionary'</strong> and find when the function '<strong>Add</strong>' is called,&nbsp;</p> <p>the error means there is an value pair with the same index already in the dictionay</p> <p>so do something like this:</p> <pre class="prettyprint">if (listdictionary.contains('key')) { //put special code here to handle adding the same key } else { listdictionary.add(...) }</pre> <p></p> <p></p> 2011-08-12T19:40:55-04:004553569http://forums.asp.net/p/1709724/4553569.aspx/1?Re+System+ArgumentException+An+entry+with+the+same+key+already+exists+Re: System.ArgumentException: An entry with the same key already exists. <p>Thanks, I'll try that!</p> 2011-08-14T21:57:56-04:004555316http://forums.asp.net/p/1709724/4555316.aspx/1?Re+System+ArgumentException+An+entry+with+the+same+key+already+exists+Re: System.ArgumentException: An entry with the same key already exists. <p>Hi,</p> <p>&nbsp;In your Program,<strong>System.Collections.Specialized.ListDictionary.Add(Object key, Object value)</strong> you can add same key in a ListDictionary.</p> <p>About hoew to use ListDictionary you can refer to the link:<a href="http://msdn.microsoft.com/en-us/library/system.collections.specialized.listdictionary.add.aspx">http://msdn.microsoft.com/en-us/library/system.collections.specialized.listdictionary.add.aspx</a></p> <p>Best Regards,</p> <p>Damon</p> 2011-08-16T06:13:59-04:00