I have a c# application which do some select in an sql server database. I use the SqlClient functions from the .net framework.
The application run at night and sometimes the application crash :
Application : XXXXX.EXE
Version du Framework : v4.0.30319
Description : le processus a été arrêté en raison d'une exception non gérée.
Informations sur l'exception : System.ComponentModel.Win32Exception
Informations sur l'exception : System.Data.SqlClient.SqlException
à System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, Boolean, System.Action`1<System.Action>)
à System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(System.Data.SqlClient.TdsParserStateObject, Boolean, Boolean)
à System.Data.SqlClient.TdsParser.TryRun(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject, Boolean ByRef)
à System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
à System.Data.SqlClient.SqlDataReader.get_MetaData()
à System.Data.SqlClient.SqlCommand.FinishExecuteReader(System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.RunBehavior, System.String)
à System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean, Boolean, Int32, System.Threading.Tasks.Task ByRef, Boolean, System.Data.SqlClient.SqlDataReader, Boolean)
à System.Data.SqlClient.SqlCommand.RunExecuteReader(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean, System.String, System.Threading.Tasks.TaskCompletionSource`1<System.Object>, Int32, System.Threading.Tasks.Task ByRef, Boolean)
à System.Data.SqlClient.SqlCommand.RunExecuteReader(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean, System.String)
à System.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior, System.String)
à System.Data.SqlClient.SqlCommand.ExecuteReader()
à XXXXX.Program.Fct01(System.String, System.String, System.String, System.Data.DataRow, System.String ByRef, System.String ByRef)
à XXXXX.Program.Gestion_Articles(System.String)
à XXXXX.Program.Main(System.String[])
The error does not occur on each run. I have some diffuclties to find the problem, when i run in debug mode, all is fine...
I wonder if it exist a tool or a way to get some additionnal informations about this crash.
Wrap it with a try/catch, then log the message and the innerException, and the task your trying to do with sql.
You can also use something like log4net (nuget package) to log the error but that's not really the issue.