I have a Windows Forms application, where the underlying database is MySql. Versions are as follows:
MySql Server v5.6
MySql Connector for .NET v6.5.4
Windows 7 64-bit
I get the error with the stack trace below, in an INTERMITTENT pattern. It happens each time in different parts of the application. Sometimes it takes a couple of days to happen, sometimes I get this 3 or 4 times a day.
On the specific occurrence where I collected this stack trace error, having the dialog box with the error still showing on the screen, I managed to open a second instance of my windows forms application, in parallel, only to notice that this second instance was working flawlessly. This is the pattern (or lack of it): whenever this issue shows up, just closing and restarting the application, or even opening another instance in parallel, is enough to restore database access. If I don't exit the application when this failure happens, all subsequent attempts the application makes to access MySql database fail, no matter what. The error dialog box option to "ignore this error and attempt to continue" allows me to conclude that it seems like MySql database backend and that particular instance of the windows forms application got "disconnected", even to subsequent attempts.
I understand that the stack trace information is a chain of events with the most recent at the top, so is it correct to assume that the failing point is at this event?
at MySql.Data.MySqlClient.NativeDriver.ExecutePacket(MySqlPacket packetToExecute)
I tried researching on this specific "MySql NativeDriver.ExecutePacket.. Object reference not set" everywhere, I could only get reports of people having this on seemingly unrelated issues with varying execution contexts, many of them even reporting as MySql bugs submitted to be fixed.
Anyway, I would appreciate any insight on the issue at hand, even suggestions on how to maybe properly debugging and even tuning MySql's configuration properties. I am open to any ideas.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at MySql.Data.MySqlClient.NativeDriver.ExecutePacket(MySqlPacket packetToExecute)
at MySql.Data.MySqlClient.NativeDriver.SendQuery(MySqlPacket queryPacket)
at MySql.Data.MySqlClient.Driver.SendQuery(MySqlPacket p)
at MySql.Data.MySqlClient.Statement.ExecuteNext()
at MySql.Data.MySqlClient.PreparableStatement.ExecuteNext()
at MySql.Data.MySqlClient.PreparableStatement.Execute()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at CodeFluent.Runtime.MySQL.CodeFluentMySQLPersistenceHook.SetForeignKeyChecks(MySqlConnection mySqlConnection)
at CodeFluent.Runtime.MySQL.CodeFluentMySQLPersistenceHook.AfterOpenConnection(IDbConnection connection)
at CodeFluent.Runtime.CodeFluentPersistence.OpenConnection()
at CodeFluent.Runtime.CodeFluentPersistence.InternalExecuteReader(CommandBehavior behavior, Boolean firstTry)
at CodeFluent.Runtime.CodeFluentPersistence.ExecuteReader(CommandBehavior behavior)
at CodeFluent.Runtime.CodeFluentPersistence.ExecuteReader()
at S5T.AssociadoSetorCob.LoadBypCodigo(Int32 pCodigo)
at S5TWin.FormGeraArqBanco.cmbSetor_MontaPesquisaTextBox(String& desc)
at S5TWin.ComboCF.txtCodigo_Leave(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnLeave(EventArgs e)
at System.Windows.Forms.Control.NotifyLeave()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1022 (RTMGDR.030319-1000)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1001 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
Long list of loaded assemblies, cut short for brevity