I'm trying to write an event log when the windows service is started. I'm using the property of the service, EventLog, which writes to the application log by default, like:
EventLog.WriteEntry("Service is starting up", EventLogEntryType.Information)
When I start the service using the net start command, it gives me
Service could not be started
error. When I remove these lines, it works just fine. Using the default:
System.Diagnostics.EventLog.WriteEntry("Application","Service is starting up", EventLogEntryType.Information)
works just fine. Why is the default not working?
There is no static
WriteEntry
method on theEventLog
class as defined in your call (one that takes astring
and aEventLogEntryType
).There is an instance method with that signature and its documentation states:
So, I assume you are using the instance method and you are failing to set the source.