I have a service that is started using a start routine surrounded by a try catch block as below.
protected override void OnStart(string[] args)
{
try
{
Program.Start();
}
catch (Exception e)
{
Logger.Error("Exception during Service Start");
}
}
Occasionally on some machines (1/100) it will occasionally print out the last line of Program.Start (a log message) and then fail with no log messages or event log messages. Should this be possible?
Thanks
EDIT: The service does kick off a few other threads but they are encapsulated in the same manner
EDIT: The Logger is a wrapper for log4net - it's working very reliably on a lot (100+) of machines (though yes it possibly the cause)
The service could crash if an exception is thrown out of a started thread but not caught.
Are you adding a handler to each app domain unhandled exception?
eg:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
EDIT Also, you have the Application.ThreadException event which i forgot to mention: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx
If the program crashes or an exception is thrown from try block, then for sure youll get Logger.Error log info but not the eventlog from system. If service crash or an unhandled exception occurs, then only eventlog on service is logged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With