Click to See Complete Forum and Search --> : Can't access event log for tasks


EricTang
January 21st, 2010, 07:16 PM
// I am trying to access the log file at "Microsoft-Windows-TaskScheduler/Operational" but get an exception

string logName = "Microsoft-Windows-TaskScheduler/Operational";
EventLog log1 = new EventLog(logName, "myMachine");

foreach( EventLogEntry entry in log1.Entries )
{

}

// threw exception: System.InvalidOperationException: The event log 'Microsoft-Windows-TaskScheduler/Operational' on computer 'myMachine' does not exist..

Does anyone know what I need to do?

BigEd781
January 21st, 2010, 07:50 PM
Perhaps you need to call "EventLog.CreateEventSource" if SourceExists returns false. Have you tried that?