0

I have a website developed in ASP.Net, using Web Forms, running and it works perfectly 99% of the time, but sometimes I notice that the website is down.

I've managed to get the error message a page method is returning when I enter the website.

{"Message":"Object reference not set to an instance of an object .","StackTrace":" em MySql.Data.MySqlClient.NativeDriver.ExecuteCommand(DBCmd cmd, Byte[] bytes, Int32 length)\r\n em MySql.Data.MySqlClient.NativeDriver.Query(Byte[] bytes, Int32 length)\r\n em MySql.Data.MySqlClient.Statement.ExecuteNext()\r\n em MySql.Data.MySqlClient.PreparableStatement.ExecuteNext()\r\n em MySql.Data.MySqlClient.PreparableStatement.Execute()\r\n em MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)\r\n em MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n em System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)\r\n em System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n em System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n em System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)\r\n em Impalce.ConexaoMySQL.ConsultarVarios(String[] sqls, List`1 parametros, Int32 tempotimeout)\r\n em Impalce.ConexaoMySQL.ConsultarVarios(String[] sqls)\r\n em _Default.CarregarTela()","ExceptionType":"System.NullReferenceException"}

The only way I managed to solve this was renaming the web.config file to something like "_web.config" and then renaming it again to "web.config".

Any ideas on how can I properly identify what is causing this problem and why renaming the web.config file "solves" it?

Like I said, the site works 99% of the time and this occurs, apparently, at random moments (I haven't identified an unsual amount of users or any other connection problems).

Any insights on why this is happening or how can I identify the problem are welcome.

Thanks in advance.

Lucas Hoffmann
  • 111
  • 1
  • 6
  • 1
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – panoskarajohn Jan 16 '20 at 20:05
  • Based on the stack trace, you need to look at the call to `Fill` within `Impalce.ConexaoMySQL.ConsultarVarios` and see what could be null in that call. – D Stanley Jan 16 '20 at 20:20
  • Since the NullReferenceException is happening in the Connector/NET code, you should post a reproducible bug report to bugs.mysql.com. Or, this may be a duplicate of this existing issue: https://bugs.mysql.com/bug.php?id=83764 – Bradley Grainger Jan 16 '20 at 22:50
  • As a workaround, you could try switching to https://www.nuget.org/packages/MySqlConnector/ - it fixes a lot of Connector/NET bugs: https://mysqlconnector.net/tutorials/migrating-from-connector-net/#fixed-bugs – Bradley Grainger Jan 16 '20 at 22:51

0 Answers0