rpzach
asked on
Security exception unhandled when trying to create/write to EventLog
Hello experts!
i've written a windows service but i'm having some issues writing to the event log which is crashing my app. i have a windows forms version of my app and this is the error I am getting:
Security exception unhandled:
The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
Here is my code to write to the logs.
Public Shared Sub LogInfo(ByVal sMessage As String)
' Write info into the event viewer
If Not System.Diagnostics.EventLo g.SourceEx ists("PopP atService" ) Then
EventLog.CreateEventSource ("PopPatSe rvice", "Application")
End If
EventLog.WriteEntry("PopPa tService", sMessage, System.Diagnostics.EventLo gEntryType .Informati on)
End Sub
Public Shared Sub LogEvent(ByVal sMessage As String)
' Write error into the event viewer
If Not EventLog.SourceExists("Pop PatService ") Then
EventLog.CreateEventSource ("PopPatSe rvice", "Application")
Else
EventLog.WriteEntry("PopPa tService", sMessage, System.Diagnostics.EventLo gEntryType .Error)
End If
End Sub
I'd like the logging available so I can track what the service is doing since it is low on communication. Any help would be appreciated!!!
i've written a windows service but i'm having some issues writing to the event log which is crashing my app. i have a windows forms version of my app and this is the error I am getting:
Security exception unhandled:
The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
Here is my code to write to the logs.
Public Shared Sub LogInfo(ByVal sMessage As String)
' Write info into the event viewer
If Not System.Diagnostics.EventLo
EventLog.CreateEventSource
End If
EventLog.WriteEntry("PopPa
End Sub
Public Shared Sub LogEvent(ByVal sMessage As String)
' Write error into the event viewer
If Not EventLog.SourceExists("Pop
EventLog.CreateEventSource
Else
EventLog.WriteEntry("PopPa
End If
End Sub
I'd like the logging available so I can track what the service is doing since it is low on communication. Any help would be appreciated!!!
ASKER
how would i adapt this to a windows form/service application? i have no web.config to set this up in... I am somewhat a n00b at win forms, if this a web app I'd be golden :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Following example is for ASP.NET but idea is same
http://geekswithblogs.net/TimH/archive/2006/04/13/75063.aspx