security problem when writing to windows application log

  • Thread starter Thread starter Rob Latour
  • Start date Start date
R

Rob Latour

The following (vb.net code) works great on 2000 and XP but not on Vista:


Dim ev As New EventLog("Application", System.Environment.MachineName,
"MyProgramName")

Dim LogText As String = "Hello world"

Dim EntryType As System.Diagnostics.EventLogEntryType =
EventLogEntryType.Information

ev.WriteEntry(LogText, EntryType, LogEventID)

ev.Close()



The following excpetion is thrown on Vista:



System.Security.SecurityException: The source was not found, but some or
all event logs could not be searched. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName,
String currentMachineName)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID)



Any ideas on what extra is needed for Vista?

Thanks in advance, Rob
 
Turns out I had to add an 'event log source'; this was not required in 2000
or xp but appears to be required in vista.

thanks, Rob

Yuriy Shkolnikov said:
Did you try running this elevated (as elevated admininstrator) ?

--
Regards,
Yuriy

This posting is provided "AS IS" with no warranties, and confers no
rights.
Rob Latour said:
The following (vb.net code) works great on 2000 and XP but not on Vista:


Dim ev As New EventLog("Application", System.Environment.MachineName,
"MyProgramName")

Dim LogText As String = "Hello world"

Dim EntryType As System.Diagnostics.EventLogEntryType =
EventLogEntryType.Information

ev.WriteEntry(LogText, EntryType, LogEventID)

ev.Close()



The following excpetion is thrown on Vista:



System.Security.SecurityException: The source was not found, but some
or
all event logs could not be searched. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at System.Diagnostics.EventLog.VerifyAndCreateSource(String
sourceName,
String currentMachineName)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID)



Any ideas on what extra is needed for Vista?

Thanks in advance, Rob
 
Back
Top