This feels like a question that has probably been asked before but I couldn't find it so am asking (possibly again).
I'm writing a windows service to do a bit of file monitoring and processing. Its all doing what I want but I am aware that there are several places that my code might throw errors when doing read/writes to the file system or event log. I'm goign to put in some try/catches where I expect there to be errors but I was wanting to do some global error handling to pick up all those unforseen problems. I'm not sure how to do this though.
My first thought was to look for some kind of global error handler similar to what I find in ASP.NET projects but couldn't see anything along these lines.
The other thought was that I could just get all my top level function calls and put a try/catch around them. As I see it that would mean putting a try/catch around all my event handler code and my service Start and Stop methods. This doesn't feel like a good way of doing it so I'm thinking I'm probably approaching this in the wrong way. Can anybody suggest what I should be doing in terms of error handling?
I assume that in a service I don't want it to just throw errors because it will potentially stop the service or should I in fact be letting the service collapse and automatically restarting it through teh recovery mechanism I've seen mentioned?
I'm very uncertain here so please share your wisdom with me... :)