Error : Hashtable insert failed. Load factor too high (Type: System.InvalidOperationException)

Symptoms:

1)      You are using .NET 3.5 sp1 for your ASP.net application and getting “Hashtable insert failed. Load factor too high” intermittently.

2)      Only way to recover from the issue to by restarting IIS.

3)      You are seeing following error, warning logged into event viewer.

Event Type:       Error
Event Source:    MyApp.Module
Event Category:              None
Event ID:            0
Date:                  6/4/2009
Time:                 11:30:55 AM
User:                  N/A
Computer:          MYCOMPUTER
Description:
ServerName=MyServer
ApplicationName=MyApp
ApplicationSubSystem=Module
Category=UIException
DateTime=06/04/2009 11:30:55 AM

Ticks=633797081958121399
Message=Type: System.InvalidOperationException
Message: Hashtable insert failed. Load factor too high.
Source: mscorlib
Target Site: Insert
StackTrace:
   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
   at System.Collections.Hashtable.set_Item(Object key, Object value)
   at System.Runtime.Serialization.SerializationEventsCache.GetSerializationEventsForType(Type t)
   at System.Runtime.Serialization.ObjectManager.RaiseOnDeserializingEvent(Object obj)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)   at System.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader)
   at Boolean check)
   at System.Web.SessionState.SessionStateItemCollection.get_Item(String name)
   at System.Web.SessionState.HttpSessionStateContainer.get_Item(String name)
   at System.Web.SessionState.HttpSessionState.get_Item(String name)
   at MyApp.UI.Common.Managers.SessionManager.get_Item(String key)
   at MyApp.UI.SharedWeb.MyBasePage.GetCurrentAccounts()
   at MyApp.UI.SharedWeb.MyBasePage.GetCurrentAccount()
   at MyApp.UI.SharedWeb.MyBasePage.get_CurrentAccount()
   at Test.PageSelfCheck()
   at MyApp.UI.SharedWeb.MyBasePage.OnLoad(EventArgs e)

Event Type:       Warning

Event Source:    ASP.NET 2.0.50727.0

Event Category:  Web Event

Event ID:            1309

Date:                  6/4/2009

Time:                 11:30:55 AM

User:                  N/A

Computer:          MYCOMPUTER

Description:

Event code: 3005

Event message: An unhandled exception has occurred.

Event time: 6/4/2009 11:30:55 AM

Event ID: c94d90ed325248c880c03c8f3d5d8488

Event sequence: 33496

Event occurrence: 13329

Event detail code: 0

 

 

Exception information:

    Exception type: InvalidOperationException

    Exception message: Hashtable insert failed. Load factor too high.

 

Thread information:

    Thread ID: 13

    Thread account name: NT AUTHORITY\NETWORK SERVICE

    Is impersonating: False

    Stack trace:    at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

   at System.Collections.Hashtable.set_Item(Object key, Object value)

   at System.Runtime.Serialization.SerializationEventsCache.GetSerializationEventsForType(Type t)

   at System.Runtime.Serialization.ObjectManager.RaiseOnDeserializingEvent(Object obj)

   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)

   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)

   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)

   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()

   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

   at System.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader)

   at System.Web.SessionState.SessionStateItemCollection.ReadValueFromStreamWithAssert()

   at System.Web.SessionState.SessionStateItemCollection.DeserializeItem(String name, Boolean check)

   at System.Web.SessionState.SessionStateItemCollection.get_Item(String name)

   at System.Web.SessionState.HttpSessionStateContainer.get_Item(String name)

   at System.Web.SessionState.HttpSessionState.get_Item(String name)

   at App.UI.SharedWeb.BasePage.get_CurrentUser()

   at App.UI.SharedWeb.BasePageHelper.GetLoggedInUserLCID()

   at App.UI.SharedWeb.BasePage.InitializeCulture()

   at ASP.summary_aspx.__BuildControlTree(summary_aspx __ctrl)

   at ASP.summary_aspx.FrameworkInitialize()

 

Cause

Apparently it is somewhere within .net framework code and seems to be related to a race condition when writing into a hashtable:

Resolution/Workaround

You can call Microsoft support and obtain the fix for 968432. Please note that there is no public hotfix for this issue yet.

 

Hope this helps!

 

Keywords: .net 3.5 SP1, InvalidOperationException, Hashtable insert failed. Load factor too high. ,System.Collections.Hashtable.Insert, System.Collections.Hashtable.set_Item