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.SqlTypes.SqlTypeFactory.GetTypeWithLen[T](Int32 length, TypeWithLenCreateDelegate createDelegate)
at NHibernate.SqlTypes.SqlTypeFactory.GetString(Int32 length)
at NHibernate.Type.TypeFactory.<RegisterDefaultNetTypes>b__d(Int32 len)
at NHibernate.Type.TypeFactory.GetType(NullableType defaultUnqualifiedType, Int32 length, GetNullableTypeWithLength ctorDelegate)
at NHibernate.Type.TypeFactory.<RegisterDefaultNetTypes>b__c(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.PersistentClass.Validate(IMapping mapping)
at NHibernate.Mapping.RootClass.Validate(IMapping mapping)
at NHibernate.Cfg.Configuration.ValidateEntities()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
….以下略过,是自己的类了
这个错误还是比较直观的,是Configuration.BuildSessionFactory()方法出了这个异常,经查证,原来是自己的代码中使用了多线程方式来进行工作,而单例内部没有控制好,在非线程安全的情况下产生了该异常。