Dictonary to ToList ArithmeticFlowException

在负载测试期间面临exception,算术导致溢出。

public static IDictionary<string, ISet> SereverConnections = new ConcurrentDictionary<string, ISet>(); public static IList GetUserConnections(string username) { //Key must not be null in any case return null if someone send and empty username if (string.IsNullOrEmpty(username)) return null; ISet connections; Global.SereverConnections.TryGetValue(username, out connections); //this will make the copy of the //return (connections != null ? connections.ToList() ?? Enumerable.Empty().ToList() : null); //exception occurs in below line. return (connections != null ? connections.ToList() : null); } 

例外:

System.OverflowException:算术运算导致溢出。 在System.Lolq.Enumerable.ToList [TSource]的System.Collections.Generic.List 1..ctor(IEnumerable 1集合)中(IEnumerable`1 source)

更新:

当我从字典中删除一些东西时,我已经分析了代码GetHashCode()调用和删除工作不正常,下面的代码出了什么问题?

  public override int GetHashCode() { int hascode = SessionID.GetHashCode(); return this.SessionID.GetHashCode();//this will uniquely } 

//我在对象的构造函数中创建会话ID,稍后没有任何赋值

 public string SessionID { get; set; } public ConnectionManager() { this.SessionID = ChatServer.SessionID.CreateNewID();// uniquely }