On startup the following exception sometimes occur. The application has multiple threads that use NHibernate separately against different databases.
System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at NHibernate.Util.ThreadSafeDictionary`2.Add(TKey key, TValue value) at NHibernate.Type.TypeFactory.AddToTypeOfNameWithLength(String key, IType type) at NHibernate.Type.TypeFactory.GetType(NullableType defaultUnqualifiedType, Int32 length, GetNullableTypeWithLength ctorDelegate) at NHibernate.Type.TypeFactory.<RegisterBuiltInTypes>b__1c(Int32 l) at NHibernate.Type.TypeFactory.BuiltInType(String typeName, Int32 length) at NHibernate.Mapping.SimpleValue.GetHeuristicType() at NHibernate.Mapping.SimpleValue.get_Type() at NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping) at NHibernate.Mapping.Property.IsValid(IMapping mapping) at NHibernate.Mapping.PersistentClass.Validate(IMapping mapping) at NHibernate.Mapping.RootClass.Validate(IMapping mapping) at NHibernate.Cfg.Configuration.ValidateEntities() at NHibernate.Cfg.Configuration.Validate() at NHibernate.Cfg.Configuration.BuildSessionFactory()
Backported to 3.3.x in 53cca9c7c09f75fe72bc91bb5519bfc3c95d5877.
Oskar Berggren September 15, 2012 at 3:27 PM
Resolved in 730c0c345102a1ffd99d78f4f6021ab911534ab1.
Oskar Berggren September 13, 2012 at 10:28 AM
AddToTypeOfNameWithLength() is called from 7 different methods. Six of those have [MethodImpl(MethodImplOptions.Synchronized)] already applied, while GetType() does not.
On startup the following exception sometimes occur. The application has multiple threads that use NHibernate separately against different databases.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at NHibernate.Util.ThreadSafeDictionary`2.Add(TKey key, TValue value)
at NHibernate.Type.TypeFactory.AddToTypeOfNameWithLength(String key, IType type)
at NHibernate.Type.TypeFactory.GetType(NullableType defaultUnqualifiedType, Int32 length, GetNullableTypeWithLength ctorDelegate)
at NHibernate.Type.TypeFactory.<RegisterBuiltInTypes>b__1c(Int32 l)
at NHibernate.Type.TypeFactory.BuiltInType(String typeName, Int32 length)
at NHibernate.Mapping.SimpleValue.GetHeuristicType()
at NHibernate.Mapping.SimpleValue.get_Type()
at NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping)
at NHibernate.Mapping.Property.IsValid(IMapping mapping)
at NHibernate.Mapping.PersistentClass.Validate(IMapping mapping)
at NHibernate.Mapping.RootClass.Validate(IMapping mapping)
at NHibernate.Cfg.Configuration.ValidateEntities()
at NHibernate.Cfg.Configuration.Validate()
at NHibernate.Cfg.Configuration.BuildSessionFactory()