When rolling through an event log using system.diagnostics.eventlog, I have to trap a
System.OverflowException (Int32 too small or large) for
what should be a string in an eventlogentry.message field that's defined as string. The problem is precisely defined in
and has been reproduced. I can't see why what should be a
string gives this exception. The same function using a
VB6 WMI call returns no problems with the message. The
text of an offending message is:
DCOM got error "General access denied error " from the
computer Web-kelly when attempting to activate the server:
{73B25FFD-F501-437B-8B11-7F0DE383964F}
For more information, see Help and Support Center at
Presumably it's the DCOM ProgID that's throwing it. Any event with a string like that throws as well. The code is:
Private Function GetEventLog(ByVal strLogType As String)
Dim myNewLog As New system.diagnostics.EventLog()
Dim strData As String
myNewLog.Log = strLogType 'System, Application, etc
myNewLog.MachineName = strComputerName
Dim entry As EventLogEntry
For Each entry In myNewLog.Entries
Dim strMessage As String
Try
strMessage = catchNulls(entry.Message)
Catch ex As System.OverflowException
strMessage = "OverFlow Exception in Message"
End Try
Dim strQuery As String = "Insert into tblEventLogs (Message) values (" & strMessage & "
"
InsertRow(strQuery)
strQuery = ""
strData = ""
Next entry
End Function
System.OverflowException (Int32 too small or large) for
what should be a string in an eventlogentry.message field that's defined as string. The problem is precisely defined in
and has been reproduced. I can't see why what should be a
string gives this exception. The same function using a
VB6 WMI call returns no problems with the message. The
text of an offending message is:
DCOM got error "General access denied error " from the
computer Web-kelly when attempting to activate the server:
{73B25FFD-F501-437B-8B11-7F0DE383964F}
For more information, see Help and Support Center at
Presumably it's the DCOM ProgID that's throwing it. Any event with a string like that throws as well. The code is:
Private Function GetEventLog(ByVal strLogType As String)
Dim myNewLog As New system.diagnostics.EventLog()
Dim strData As String
myNewLog.Log = strLogType 'System, Application, etc
myNewLog.MachineName = strComputerName
Dim entry As EventLogEntry
For Each entry In myNewLog.Entries
Dim strMessage As String
Try
strMessage = catchNulls(entry.Message)
Catch ex As System.OverflowException
strMessage = "OverFlow Exception in Message"
End Try
Dim strQuery As String = "Insert into tblEventLogs (Message) values (" & strMessage & "
InsertRow(strQuery)
strQuery = ""
strData = ""
Next entry
End Function