0

I have a small database used for a C# WinForms with Mysql Net Connector. All worked well during localhost development but when I moved it to a GoDaddy hosting I started getting 'ContextSwitchDeadlock'. I suspect this is because the server is rejecting the new connections as the programs starts okey and open the first connection but as I try to recover data from it, it stops responding. I use this main schema in most of the forms.

try
{
    Using(MySqlConnection Connection = new MySqlConnection("ConnectionString"))
   {
      Connection.Open();
      //Fetching Data putting in Combobox,Textbox,DatagridView etc.
   }
}
catch(MySqlException ex)
{
    //Handling
}

This is in most forms OnLoad event, so each time a form is opened a new connection is opened. Im aware of Connection pooling so I opened a connection in the main form and in the next one I did just

  Using(MySqlConnection Connection = new MySqlConnection())
 {
  Connection.Open();
 }

I also disabled the exeption in the debugger options but it just no longer fetch data after some queries.

  • Possible duplicate of [Visual Studio: ContextSwitchDeadlock](https://stackoverflow.com/questions/578357/visual-studio-contextswitchdeadlock) – Bradley Grainger Aug 15 '18 at 19:08
  • Disabling the `ContextSwitchDeadlock` Managed Debugging Assistant may let you work around the issue. (I assume you moved just your MySQL Server to GoDaddy hosting, not the Windows Forms application, correct?) – Bradley Grainger Aug 15 '18 at 19:09
  • Yes, I also disabled it in the past sorry I forgot to mention it. But the form just won´t retrieve more data after a couple of queries. It does fetch some data but doesnt finish. – José González Aug 15 '18 at 20:31
  • What's your full connection string (without the password)? Are you setting the `ConnectionTimeout` setting? What happens if you leave that at its default of 15 (or reduce it to, say, 5)? Do you get an exception? If so, what are the full exception details? – Bradley Grainger Aug 15 '18 at 20:44
  • It looks like this one Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername; Pwd=myPassword;Convert Zero Datetime=True; – José González Aug 15 '18 at 21:28
  • I tried applying the ConnectionTimeOut with five seconds and the first form won´t even start. – José González Aug 16 '18 at 00:06
  • I suspect you're getting a `MySqlException` but it's being caught during form startup and preventing it from being displayed. Try enabling "Break on exceptions" in VS and seeing if you can get the exception details: http://idownvotedbecau.se/noexceptiondetails/ – Bradley Grainger Aug 16 '18 at 03:58
  • I did, with no different results. My guess is that the server is not permiting more queries. I doesn´t seem to be an issue with the connection but with the amount of queries. – José González Aug 17 '18 at 00:46

0 Answers0