I have a Windows Service that runs every 10 minutes. Whenever there is an error on the DLL, the service isn't throwing an error. How do I make it so the error propagates back to the Windows Service and have it gene开发者_如何学Pythonrate an Event Viewer message, or even start the polling again?
catch (Exception ex)
{
var errorMessage = ex.Message;
if (ex.InnerException != null)
errorMessage += " " + ex.InnerException.Message;
eventLog1.WriteEntry(errorMessage, EventLogEntryType.Error);
new Logging().LogMessageToFile(errorMessage, true);
}
Problem solved! Throw it again AFTER catching it.
catch (Exception ex)
{
var errorMessage = ex.Message;
if (ex.InnerException != null)
errorMessage += " " + ex.InnerException.Message;
eventLog1.WriteEntry(errorMessage, EventLogEntryType.Error);
new Logging().LogMessageToFile(errorMessage, true);
throw;
}
精彩评论