catch (Exception e)
{
_status.currentState = ServiceControlStatus.STATE_PAUSED;
- WriteLogEntry(SR.Format(SR.ContinueFailed, e), true);
+ WriteLogEntry(SR.Format(SR.ContinueFailed, e), EventLogEntryType.Error);
// We re-throw the exception so that the advapi32 code can report
// ERROR_EXCEPTION_IN_SERVICE as it would for native services.
}
catch (Exception e)
{
- WriteLogEntry(SR.Format(SR.CommandFailed, e), true);
+ WriteLogEntry(SR.Format(SR.CommandFailed, e), EventLogEntryType.Error);
// We should re-throw the exception so that the advapi32 code can report
// ERROR_EXCEPTION_IN_SERVICE as it would for native services.
catch (Exception e)
{
_status.currentState = ServiceControlStatus.STATE_RUNNING;
- WriteLogEntry(SR.Format(SR.PauseFailed, e), true);
+ WriteLogEntry(SR.Format(SR.PauseFailed, e), EventLogEntryType.Error);
// We re-throw the exception so that the advapi32 code can report
// ERROR_EXCEPTION_IN_SERVICE as it would for native services.
}
catch (Exception e)
{
- WriteLogEntry(SR.Format(SR.PowerEventFailed, e), true);
+ WriteLogEntry(SR.Format(SR.PowerEventFailed, e), EventLogEntryType.Error);
// We rethrow the exception so that advapi32 code can report
// ERROR_EXCEPTION_IN_SERVICE as it would for native services.
}
catch (Exception e)
{
- WriteLogEntry(SR.Format(SR.SessionChangeFailed, e), true);
+ WriteLogEntry(SR.Format(SR.SessionChangeFailed, e), EventLogEntryType.Error);
// We rethrow the exception so that advapi32 code can report
// ERROR_EXCEPTION_IN_SERVICE as it would for native services.
{
_status.currentState = previousState;
SetServiceStatus(_statusHandle, pStatus);
- WriteLogEntry(SR.Format(SR.StopFailed, e), true);
+ WriteLogEntry(SR.Format(SR.StopFailed, e), EventLogEntryType.Error);
throw;
}
}
}
catch (Exception e)
{
- WriteLogEntry(SR.Format(SR.ShutdownFailed, e), true);
+ WriteLogEntry(SR.Format(SR.ShutdownFailed, e), EventLogEntryType.Error);
throw;
}
}
service.Dispose();
if (!res)
{
- service.WriteLogEntry(SR.Format(SR.StartFailed, errorMessage), true);
+ service.WriteLogEntry(SR.Format(SR.StartFailed, errorMessage), EventLogEntryType.Error);
}
}
}
}
catch (Exception e)
{
- WriteLogEntry(SR.Format(SR.StartFailed, e), true);
+ WriteLogEntry(SR.Format(SR.StartFailed, e), EventLogEntryType.Error);
_status.currentState = ServiceControlStatus.STATE_STOPPED;
// We capture the exception so that it can be propagated
if (_statusHandle == (IntPtr)0)
{
string errorMessage = new Win32Exception().Message;
- WriteLogEntry(SR.Format(SR.StartFailed, errorMessage), true);
+ WriteLogEntry(SR.Format(SR.StartFailed, errorMessage), EventLogEntryType.Error);
}
_status.controlsAccepted = _acceptedCommands;
statusOK = SetServiceStatus(_statusHandle, pStatus);
if (!statusOK)
{
- WriteLogEntry(SR.Format(SR.StartFailed, new Win32Exception().Message), true);
+ WriteLogEntry(SR.Format(SR.StartFailed, new Win32Exception().Message), EventLogEntryType.Error);
_status.currentState = ServiceControlStatus.STATE_STOPPED;
SetServiceStatus(_statusHandle, pStatus);
}
}
}
- private void WriteLogEntry(string message, bool error = false)
+ private void WriteLogEntry(string message, EventLogEntryType type = EventLogEntryType.Information)
{
// EventLog failures shouldn't affect the service operation
try
{
if (AutoLog)
{
- EventLog.WriteEntry(message);
+ EventLog.WriteEntry(message, type);
}
}
catch