T
Tlink
I am trying to write to the event log using the following code from a aspx
page benhind code.
Function WriteEventlog(ByVal LogName, ByVal MachineName, ByVal
Source, ByVal EventMessage, ByVal EventID, ByRef Category, ByRef
ErrorResults)
***values TLN
..(Dot) "" "Test 1"
0 0 "" ****
Dim sSource As String
Dim sLog As String
Dim sEvent As String
Dim sMachine As String
Try
If Source = "" Then sSource = "EProcessController" Else
sSource = Source
If LogName = "" Then
sLog = "Application"
Else
sLog = LogName
End If
If MachineName = "" Then
sMachine = "."
Else
sMachine = MachineName
End If
If Not EventLog.SourceExists(sSource, sMachine) Then
EventLog.CreateEventSource(sSource, sLog, sMachine)
End If
If EventID > 0 Then
EventLog.WriteEntry(sSource, EventMessage,
EventLogEntryType.Error, EventID, Category)
Else
EventLog.WriteEntry(sSource, EventMessage,
EventLogEntryType.Information, EventID, Category)
End If
Catch ex As Exception
ErrorResults = ex.ToString
End Try
End Function
Results in the following error:
System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at Inbizness.DefaultLibrary.WriteEventlog(Object LogName, Object
MachineName, Object Source, Object EventMessage, Object EventID, Object&
Category, Object& ErrorResults) in
D:\Dev\OrderingSystem\code\TClass\Class1.vb:line 381"
I have set the relevant registry key to allow the r/w of the event log yet
no go.
page benhind code.
Function WriteEventlog(ByVal LogName, ByVal MachineName, ByVal
Source, ByVal EventMessage, ByVal EventID, ByRef Category, ByRef
ErrorResults)
***values TLN
..(Dot) "" "Test 1"
0 0 "" ****
Dim sSource As String
Dim sLog As String
Dim sEvent As String
Dim sMachine As String
Try
If Source = "" Then sSource = "EProcessController" Else
sSource = Source
If LogName = "" Then
sLog = "Application"
Else
sLog = LogName
End If
If MachineName = "" Then
sMachine = "."
Else
sMachine = MachineName
End If
If Not EventLog.SourceExists(sSource, sMachine) Then
EventLog.CreateEventSource(sSource, sLog, sMachine)
End If
If EventID > 0 Then
EventLog.WriteEntry(sSource, EventMessage,
EventLogEntryType.Error, EventID, Category)
Else
EventLog.WriteEntry(sSource, EventMessage,
EventLogEntryType.Information, EventID, Category)
End If
Catch ex As Exception
ErrorResults = ex.ToString
End Try
End Function
Results in the following error:
System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at Inbizness.DefaultLibrary.WriteEventlog(Object LogName, Object
MachineName, Object Source, Object EventMessage, Object EventID, Object&
Category, Object& ErrorResults) in
D:\Dev\OrderingSystem\code\TClass\Class1.vb:line 381"
I have set the relevant registry key to allow the r/w of the event log yet
no go.