>Didn't realize you were using System.Diagnostics. The most likely cause of your problem is that you are attempting to read a log entry where the relevant log is not found. Try something like this to test (It's a C# console example but easily converted to VB):
> 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....
Thanks
The event log, in such situation, is found as I can collect dozen of other properties. So, globalizing all this into a Try/Catch to avoid that situation will probably not change anything.
That specific line of declaration translates to this in VB.Net:
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?