Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2004, 12:38 PM
CBS CBS is offline
Registered User
 
Join Date: Aug 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Item has already been added. Key in dictionary

The mscorlib.dll throws the above exception when adding objects to a hashtable. This is despite the code being within a synclock statement. My understanding is that the error is a thread issue and should be prevented by Synclock statements. The code is unchanged so it should not have stopped working. Does anybody know of any known bugs or possible explanations? Below is an example of the code. Note that MyBase refers to a hashtable as the class is inherited from one.

SyncLock MyBase.SyncRoot
  try
     MyBase.Add(NewBusinessObject.UniqueID, NewBusinessObject)
     Catch e As Exception
         Throw exception
  End Try
End SyncLock


 
Old August 26th, 2004, 05:37 AM
CBS CBS is offline
Registered User
 
Join Date: Aug 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Apologies. It was not a bug after all, but a genuine duplicate in the hash table caused by rogue data.

 
Old November 23rd, 2006, 10:07 AM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I am getting the Similar error
will you please help me in C#

here is the error
---------------------------------------------------------------------

Item has already been added. Key in dictionary: "en-GB" Key being added: "en-GB"
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.

Exception Details: System.ArgumentException: Item has already been added. Key in dictionary: "en-GB" Key being added: "en-GB"

Source Error:

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.

Stack Trace:


[ArgumentException: Item has already been added. Key in dictionary: "en-GB" Key being added: "en-GB"]
   System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) +955
   System.Collections.Hashtable.Add(Object key, Object value) +11
   System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) +571
   System.Resources.ResourceManager.GetString(String name, CultureInfo culture) +103
   System.Web.HttpRuntime.GetResourceStringFromResour ceManager(String key) +184
   System.Web.UI.WebControls.BaseValidator.RegisterVa lidatorCommonScript() +127
   System.Web.UI.WebControls.BaseValidator.OnPreRende r(EventArgs e) +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +62
   System.Web.UI.Control.PreRenderRecursiveInternal() +125
   System.Web.UI.Control.PreRenderRecursiveInternal() +125
   System.Web.UI.Control.PreRenderRecursiveInternal() +125
   System.Web.UI.Control.PreRenderRecursiveInternal() +125
   System.Web.UI.Control.PreRenderRecursiveInternal() +125
   System.Web.UI.Control.PreRenderRecursiveInternal() +125
   System.Web.UI.Page.ProcessRequestMain() +1476




----------------------------------------------------------------------

Regards
SRee

A curve that can set lot of things i.e Smile





Similar Threads
Thread Thread Starter Forum Replies Last Post
Primary key has nullable item BaNSHee SQL Server 2005 1 January 15th, 2008 12:09 AM
The given key was not present in the dictionary charnata ASP.NET 2.0 Professional 1 May 26th, 2006 12:07 PM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Find Out First Item of each item Group Jane SQL Language 1 November 22nd, 2003 12:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.