Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detect Event Viewer Keywords null value
Message
De
11/01/2017 08:55:15
 
 
À
11/01/2017 04:53:22
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:
01646513
Vues:
20
>That throws an exception for me. Here's my current test code :
>        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 Function
I'm guessing that the error occurs because of omissions in the registry which prevents some items being resolved.

Have you been able to allocate the error being thrown at the Keywords level or at the KeywordsDisplayNames? I am guess that would be at the KeywordsDisplayNames level.

I am also assuming you get a null for result, even if you have the if() in there. Is that correct?
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