My application crashes due to this exception:
Exception Info: System.NotSupportedException
at System.Net.Security._SslStream.ProcessRead(Byte[], Int32, Int32, System.Net.AsyncProtocolRequest)
at System.Net.Security.SslStream.Read(Byte[], Int32, Int32)
at MySql.Data.MySqlClient.TimedStream.Read(Byte[], Int32, Int32)
at MySql.Data.MySqlClient.MySqlStream.ReadFully(System.IO.Stream, Byte[], Int32, Int32)
at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32 ByRef, Int64 ByRef)
at MySql.Data.MySqlClient.Driver.GetResult(Int32, Int32 ByRef, Int64 ByRef)
at MySql.Data.MySqlClient.Driver.NextResult(Int32, Boolean)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlDataReader.Close()
at MySql.Data.MySqlClient.MySqlConnection.Close()
at MySql.Data.MySqlClient.MySqlConnection.Dispose(Boolean)
at MySql.Data.MySqlClient.MySqlConnection.Finalize()
I've tried to upgrade to the latest framework, and downloaded the newest version of MySql.Data file.
This is how one of my query methods looks like. The other query methods follows the same structure.
public static long InsertReturnInsertedAutoIncID(string queryStr, string[,] Parameters)
{
int attempts = 0;
do
{
try
{
attempts++;
long autoIncID;
using (MySqlConnection dbObj = new MySqlConnection(connectionToDBstring))
{
dbObj.Open();
using (MySqlCommand query = new MySqlCommand(queryStr, dbObj))
{
// Add parameters to query (as we don't want to concatinate)
for (int i = 0; i < Parameters.GetLength(0); i++)
{
query.Parameters.AddWithValue(Parameters[i, 0], Parameters[i, 1]);
}
query.ExecuteNonQuery();
autoIncID = query.LastInsertedId;
}
}
return autoIncID;
}
catch (Exception ex)
{
Logger.Log.Error(ex.ToString());
if (attempts >= maxAttempts)
{
return -1;
}
System.Threading.Thread.Sleep(200);
}
} while (true);
}
I have many threads(tasks) running in my application which queries the DB. There's no locks used since the threads should not be on hold for too long. This issue happends very rarely (Like every 7 day or so). I'm expecting this exception to not happend at all, but if I could just ignore the exception that would also be fine, I would just retry the query then. The issue is that this exception causes my application to stop working (Since the application is getting a "Application has stopped working" window.)