我在外部代码中收到参数异常未处理错误Item has already been added. Key in dictionary: 'MODES' Key being added 'MODES'
并且源代码不可用,因为它不是我的代码。我很困惑,因为我没有在代码中的字典中添加任何内容。
我正在收听挂起和恢复事件,并且错误发生在恢复时(我认为)。我该如何解决?
这是我添加的开始导致错误的代码:
private void SystemEvents_PowerModeChanged(Object sender, PowerModeChangedEventArgs e)
{
Console.WriteLine("RECIEVED SIGNAL: " + e.Mode);
if (e.Mode.Equals(PowerModes.Suspend)) //computer going to sleep
{
if (bots != null && bots.Count > 0)
foreach (KeyValuePair<string,irc> b in bots)
{
b.Value.disconnect();
}
}
else if (e.Mode.Equals(PowerModes.Resume)) //computer waking up
{
if (bots != null && bots.Count > 0)
foreach (KeyValuePair<string, irc> b in bots)
{
b.Value.connect();
}
}
}
错误截图:http: //i.imgur.com/Wm7Z5Iw.png