.Net Windows Service Throws EventType clr20r3 system.data.sqlclient.sql error

I have a Windows.Net/C# 2.0 service. The entry point is wrapped in a try catch block that notifies me of problems and allows the service to continue working fine, but when I look at the server application event log, I see several "EventType clr20r3" errors that cause the service to die unexpectedly. The catch block has "catch (Exception ex)" and does not cancel the exception.

Each sql command is of type "CommandType.StoredProcedure" and is executed using a SqlDataReader. These sproc calls function correctly 99% of the time and have all gone through rigorous modularity testing, profiling, and QA'd. I have additionally wrapped these calls in try catch blocks to be sure and I am still experiencing these unhandled exceptions.

This is only in our production environment and cannot be duplicated in our dev or staging environments (even under heavy load).

Why won't my error handling catch this particular error? Is there anyway to better understand the root cause of the problem?

Here is an example of an event log:

EventType clr20r3, P1 RDC.OrderProcessorService, 
P2 1.0.0.0, 
P3 4ae6a0d0, 
P4 system.data, 
P5 2.0.0.0, P6 4889deaf, 
P7 2490, 
P8 2c, 
P9 system.data.sqlclient.sql, 
P10 NIL.

      

Additionally

The Order Processor service terminated unexpectedly.  
It has done this 1 time(s).  
The following corrective action will be taken in 60000 milliseconds: 
Restart the service.

      

+2


a source to share


2 answers


Reply from comments. I am glad to help.:)



Have you tried adding an AppDomain.UnhandledException Event handler? msdn.microsoft.com/en-us/library / ... Pretty much the problem is that you have an unhandled SQL exception somewhere in your code.

Not necessarily, but without seeing your code or the libraries you are using there is no way to know if the exception is happening in another thread, in a third party library, etc ... By passing the AppDomain.UnhandledException handler, you should at least detail exceptions and find out where your problem point is. Just throw an EventArg for ((Exception) e.ExceptionObject) .message and you should at least have an idea where your unhandled exception is.

+3


a source


This error most likely happens on a thread other than your entry point.

You also need to define exception handling for your background threads.



If you are using WCF to port your service, you have the ability to define how errors and other exceptions are handled. Is this how you host your service?

EDIT: If you are not creating anything asynchronously and are not using the WCF / etc application, try to handle the AppDomain.UnhandledException and log the detailed error there.

+1


a source







All Articles