G
Guest
Hi all,
I want to assign a new key value to my hash table (okay, I use the
Specialized.NameValueCollection, but this collection is based again on the
HashTable). When the key already exists, then the value of the key shall be
replaced. That's why I use the Add method which also replaces key values
instead of Insert which fires exceptions when a key already exist.
Now, I've got a very strange exception:
----SNIP----
System.ArgumentException: Das Element wurde bereits hinzugefügt. Schlüssel
im Wörterbuch: "color_anchor_NavHeader2_all" Hinzuzufügender Schlüssel:
"color_anchor_NavHeader2_all"
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String
name, Object value)
at System.Collections.Specialized.NameObjectCollectionBase.BaseSet(String
name, Object value)
at System.Collections.Specialized.NameValueCollection.Set(String name,
String value)
at System.Collections.Specialized.NameValueCollection.set_Item(String name,
String value)
at
BOMAG.CorporateWebSite.DealerCustomizing.LoadDealerConfigurationSetting(String propertyName, DealerLookupModes dealerLookupMode)
at _ASP.style_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain()
----/SNIP----
The add method is called, it identifies the key as missing and that's why it
calls the Insert method internally. Then, the Insert method wants to insert
the key - but by whatever reason, the insert fails because the key already
exist. Somewhere between the execution of the IF in the Add method and the
key-insertion in Insert, the key must have been created.
So, I can only imaging that another process (very normal for web solutions)
might be more fast and inserted the key value in the meanwhile.
Is this a bug or is it a feature?
Thanks for any advise!
Regards
Jochen
I want to assign a new key value to my hash table (okay, I use the
Specialized.NameValueCollection, but this collection is based again on the
HashTable). When the key already exists, then the value of the key shall be
replaced. That's why I use the Add method which also replaces key values
instead of Insert which fires exceptions when a key already exist.
Now, I've got a very strange exception:
----SNIP----
System.ArgumentException: Das Element wurde bereits hinzugefügt. Schlüssel
im Wörterbuch: "color_anchor_NavHeader2_all" Hinzuzufügender Schlüssel:
"color_anchor_NavHeader2_all"
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String
name, Object value)
at System.Collections.Specialized.NameObjectCollectionBase.BaseSet(String
name, Object value)
at System.Collections.Specialized.NameValueCollection.Set(String name,
String value)
at System.Collections.Specialized.NameValueCollection.set_Item(String name,
String value)
at
BOMAG.CorporateWebSite.DealerCustomizing.LoadDealerConfigurationSetting(String propertyName, DealerLookupModes dealerLookupMode)
at _ASP.style_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain()
----/SNIP----
The add method is called, it identifies the key as missing and that's why it
calls the Insert method internally. Then, the Insert method wants to insert
the key - but by whatever reason, the insert fails because the key already
exist. Somewhere between the execution of the IF in the Add method and the
key-insertion in Insert, the key must have been created.
So, I can only imaging that another process (very normal for web solutions)
might be more fast and inserted the key value in the meanwhile.
Is this a bug or is it a feature?
Thanks for any advise!
Regards
Jochen