It happened before, I changed my dictionary (Dictionary) into ConcurrentDictionary, and it fixed. But when i changed the things, (dictionarys stays same) things gone wrong.
Here is my full Code: http://pasted.co/fd94e190
It says List is null that is from this method.
Models.GridData getCurrentGrid()
{
Models.GridData data = new Models.GridData();
for (int i = 0; i < metroGrid1.Rows.Count; i++)
{
foreach (var item in metroGrid1.Rows[i].Cells)
{
if (item is DataGridViewCell)
{
Models.CellData cellData = new Models.CellData();
DataGridViewCell cell = item as DataGridViewCell;
cellData.column = cell.ColumnIndex;
cellData.row = cell.RowIndex;
if (string.IsNullOrEmpty((string)cell.Value) && string.IsNullOrWhiteSpace((string)cell.Value))
{
cellData.value = string.Empty;
}
else {
cellData.value = cell.Value;
}
//Occurs here right now
data.List.TryAdd(cellData.column.ToString() + " " + cellData.row.ToString(),cellData);
}
}
}
return data;
}
void Save()
{
Models.GridData data = new Models.GridData();
data = getCurrentGrid();
unsavedChanges = false;
StreamWriter writer = new StreamWriter(path);
writer.AutoFlush = true;
writer.Write(JsonConvert.SerializeObject(data.List));
writer.Close();
MetroFramework.MetroMessageBox.Show(this, "Başarıyla kaydedildi", "Yoklama Listesi-Talha Açıkgöz", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
EDIT: Models.cs = http://pasted.co/13a7cb1c