Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detect Event Viewer Keywords null value
Message
De
10/01/2017 05:32:06
 
 
À
09/01/2017 11:52:05
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:
01646441
Vues:
26
>>A .Net long (Int64) is never null (unless you use a nullable type) - it's a value reference. Are you confusing it with the DBType (which can be nullable)
>
>The event viewer object I receive has it as null, in a new environment we are using. Under 2008, I use to have a numeric value in there. But, under 2012, it is null. So, when this is transfered into the table, it ends up as a null. So, I thought I would detect its null value, before saving, and adjust accordingly. However, the event viewer object is a beast on its own as not everything is accessible in conventional ways. I cannot even compare .HasValue as it will not detect it is null. So, even with that, I ended up with a null value in the table. For now, I had to put it in comment.

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....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform