>> Dim loEventLogReader As New EventLogReader("D:\\Event.evtx", PathType.FilePath) >> Dim loEventLogRecord As EventLogRecord = Nothing >> >> While (InlineAssignHelper(loEventLogRecord, DirectCast(loEventLogReader.ReadEvent(), EventLogRecord))) IsNot Nothing >> Try >> Dim result As Int64 = If(loEventLogRecord.Keywords, 0) >> Console.WriteLine(loEventLogRecord.TimeCreated.ToString() + ": " + result.ToString()) >> Dim final As String = String.Empty >> 'Exception thrown here when accessing KeywordsDisplayNames >> For Each lcString As String In loEventLogRecord.KeywordsDisplayNames >> final += lcString & Convert.ToString(",") >> Next >> If final.Length > 0 Then >> final = final.Substring(0, final.Length - 1) >> End If >> Console.WriteLine(final) >> Catch ex As Exception >> Console.WriteLine("Exception at {0} : {1} ", loEventLogRecord.TimeCreated.ToString(), ex.Message) >> End Try >> End While >> Console.ReadLine()Oh, and the helper method:
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T >> target = value >> Return value >> End FunctionI'm guessing that the error occurs because of omissions in the registry which prevents some items being resolved.