- Feb 13, 2003
- 26,256
- 406
- 126
I'm working on a Windows Service that processes thousands of user records from a database and sends out emails to them. A record is written to a log table after each user record is processed so the service can pick up where it left off in case of a failure somewhere.
The service uses LINQ to SQL for data access. We ran a test and and unknowingly had the incorrect db connection string in the config file, so the service would just hang and not throw any exceptions when it could not connect to the database (strange, perhaps that's just LINQ).
So I was told to add a bunch of WriteEntry() calls to the EventLog object in order to find the source of the problem. We eventually found it was because of the connection string, but the calls stayed in the service.
We ended up having major problems with the service: it would hang at a few different parts of execution, and then would not even be able to be stopped without hitting Stop twice and waiting awhile. Trying to start it would give an error: "Service started and then stopped. Some services automatically...".
Google search brought me to a page where a guy said after clearing the EventViewer for the service he was able to start it again. That got me thinking so I removed all of the WriteEntry() calls in the service except for one that outputted how many records it was processing so I could check that number against the number of records in the log table.
It ended up working. Before it would only get through about 150 records until the service hung up; removing all EventLog.WriteEntry calls but that one let the service get through all 9461 records it needed to process.
The past two days have been the most stressful I've ever had at a job because of these problems. So long story short: watch how many entries you write to the EventLog! If this even helps one person save their hair from turning gray, or losing it, I'll be happy.
Maybe its the speed at which the entries were written, because it usually hung up around 2,000 - 2,200 entries in the event log for the service. And that's not much compared to the 10,000+ that were in the Security log on my work machine.
The service uses LINQ to SQL for data access. We ran a test and and unknowingly had the incorrect db connection string in the config file, so the service would just hang and not throw any exceptions when it could not connect to the database (strange, perhaps that's just LINQ).
So I was told to add a bunch of WriteEntry() calls to the EventLog object in order to find the source of the problem. We eventually found it was because of the connection string, but the calls stayed in the service.
We ended up having major problems with the service: it would hang at a few different parts of execution, and then would not even be able to be stopped without hitting Stop twice and waiting awhile. Trying to start it would give an error: "Service started and then stopped. Some services automatically...".
Google search brought me to a page where a guy said after clearing the EventViewer for the service he was able to start it again. That got me thinking so I removed all of the WriteEntry() calls in the service except for one that outputted how many records it was processing so I could check that number against the number of records in the log table.
It ended up working. Before it would only get through about 150 records until the service hung up; removing all EventLog.WriteEntry calls but that one let the service get through all 9461 records it needed to process.
The past two days have been the most stressful I've ever had at a job because of these problems. So long story short: watch how many entries you write to the EventLog! If this even helps one person save their hair from turning gray, or losing it, I'll be happy.
Maybe its the speed at which the entries were written, because it usually hung up around 2,000 - 2,200 entries in the event log for the service. And that's not much compared to the 10,000+ that were in the Security log on my work machine.
