> EventLogReader loEventLogReader = new EventLogReader("Application"); > EventLogRecord loEventLogRecord = null; > > while (true) > { > > try > { > loEventLogRecord = (EventLogRecord)loEventLogReader.ReadEvent(); > if (loEventLogRecord == null) > { > Console.WriteLine("End of Log"); > break; > } > > Int64 result = loEventLogRecord.Keywords ?? 0; > Console.WriteLine(loEventLogRecord.TimeCreated.ToString()+": "+result.ToString()); > string final = string.Empty; > foreach (string lcString in loEventLogRecord.KeywordsDisplayNames) > { > final += lcString + ","; > } > if (final.Length > 0) > { > final = final.Substring(0, final.Length - 1); > } > Console.WriteLine(final); > } > catch (Exception Ex) > { > Console.WriteLine("EventLog not found at {0} for {1} ",loEventLogRecord.TimeCreated.ToString(), loEventLogRecord.ProviderName); > } > } > Console.ReadLine();If you break on the exception you will see that Keywords and KeywordsDisplayNames both throw an exception....
Dim result As Int64 = If(loEventLogRecord.Keywords, 0)I am not sure about that syntax. Is it that part of the code you wanted to mention that could resolve the issue?