I am getting error System.ArgumentException: An item with the same key has already been added
while executing following code.
The problem is Sometimes i get this error after 1 hour since program start, sometimes in 5 minutes. It depends.
I try to explain all details and couldn't find the reason for that.
public void getWE()
{
if (uceTopActivity.SelectedIndex == 0)
{
if (dtTopAll.AsEnumerable().Any() == true)
{
maxDate = dtTopAll.AsEnumerable().Max(z => z.Field<DateTime>("SAMPLE_TIME"));
}
var isFull = (dtTopAll.AsEnumerable().Where(l => l.Field<DateTime>("SAMPLE_TIME") == maxDate && l.Field<double>("WAITS") != 0)).Any();
if (isFull == true)
{
var dt1 = (from dr1 in dtTopAll.AsEnumerable()
where dr1.Field<DateTime>("SAMPLE_TIME") == maxDate && dr1.Field<double>("WAITS") != 0
group dr1 by dr1.Field<string>("Event") into g
select new
{
Event = g.Key,
WAITS = g.Sum(z => z.Field<double>("WAITS"))
}).ToDataTable();
ugWaitEvent.DataSource = dt1;
ugWaitEvent.DisplayLayout.Bands[0].Columns[1].Header.Caption = "Waits (ms/s)";
ugWaitEvent.DisplayLayout.Bands[0].Columns[0].Width = 190;
ugWaitEvent.DisplayLayout.Bands[0].Columns[1].SortIndicator = SortIndicator.Descending;
}
else
{
ugWaitEvent.DataSource = null;
}
}
}
Here is the snapshot of the error;
And It has 3 exception. How can i use these exceptions tabs to get which function and which form control gets the error ;
Then when i search for Dictionary Word i got below lines on its Designer.cs;
global::System.Collections.Generic.Dictionary<object, global::System.Data.IDbConnection> revertConnections = new global::System.Collections.Generic.Dictionary<object, global::System.Data.IDbConnection>();
global::System.Collections.Generic.IDictionary<global::System.Data.DataRow, global::System.Data.DataRow> traversedRows = new global::System.Collections.Generic.Dictionary<global::System.Data.DataRow, global::System.Data.DataRow>();