Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detect Event Viewer Keywords null value
Message
De
10/01/2017 08:36:21
 
 
À
10/01/2017 05:32:06
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows Server 2012
Database:
Visual FoxPro
Application:
Web
Divers
Thread ID:
01646401
Message ID:
01646449
Vues:
18
>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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform