Sometimes I get this error in the server:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
-StackTrace-
at System.Collections.BitArray.Get(Int32 index)
at System.Data.DataSet.MarkModifiedRows(TableChanges[] bitMatrix, DataRowState rowStates)
at System.Data.DataSet.GetChanges(DataRowState rowStates)
at System.Data.DataSet.GetChanges()
at MapNetService.DataAccess.GPSDataProcessingProvider.Flush(String name)
I have two servers (production and test) that handle some data and mostly get this error only in one server
The function is very simple
public void Flush(string name)
{
bool isSuccess = true;
try
{
GPSDataProcessingDS changedData = (GPSDataProcessingDS)gpsData.GetChanges();
gpsData.AcceptChanges();
RemoveExcessiveRows(name, gpsData.tblGPSReport);
RemoveExcessiveRows(name, gpsData.tblIOReport);
if (changedData != null
&& (changedData.tblGPSReport.Count > 0 || changedData.tblIOReport.Count > 0
|| changedData.tblLastGPSReadings.Count > 0))
{
isSuccess = SaveChanges(changedData);
}
else
{
Trace.WriteLine("No changes to flush.");
}
}
catch (Exception e)
{
Logger.Log(name, "Flushing exception:" + e.Message);
try
{
if (gpsData.HasErrors)
{
if (gpsData.tblGPSReport.GetErrors().Length > 0)
{
foreach (var error in gpsData.tblGPSReport.GetErrors())
{
Logger.Log(name, "Error:" + error.RowError);
}
}
if (gpsData.tblIOReport.GetErrors().Length > 0)
{
foreach (var error in gpsData.tblIOReport.GetErrors())
{
Logger.Log(name, "Error:" + error.RowError);
}
}
if (gpsData.tblLastGPSReadings.GetErrors().Length > 0)
{
foreach (var error in gpsData.tblLastGPSReadings.GetErrors())
{
Logger.Log(name, "Error:" + error.RowError);
}
}
}
}
catch
{
// ignored
}
gpsData.RejectChanges();
throw;
}
}
The GetErrors() return nothing
Thanks a lot