This documentation is archived and is not being maintained.

EventLogEntry.Message Property

Gets the localized message associated with this event entry.

[Visual Basic]
Public ReadOnly Property Message As String
[C#]
public string Message {get;}
[C++]
public: __property String* get_Message();
[JScript]
public function get Message() : String;

Property Value

The formatted, localized text for the message. This includes associated replacement strings.

Exceptions

Exception Type Condition
Exception The space could not be allocated for one of the insertion strings associated with the message.

Remarks

Getting this property opens the registry to determine the filename of the .dll file containing the localized text. If you receive a registry error when testing your source code, verify the .dll file's existence on the computer. If insertion strings are included in the message, catch errors in their allocation.

Example

[Visual Basic] 
Option Strict
Option Explicit

Imports System
Imports System.Diagnostics
Imports Microsoft.VisualBasic

Class MySample
    Public Shared Sub Main()
        
        Dim myLog As New EventLog()
        myLog.Log = "MyNewLog"
        Dim entry As EventLogEntry
        For Each entry In  myLog.Entries
            Console.WriteLine((ControlChars.Tab & "Entry: " & entry.Message))
        Next entry
    End Sub ' Main
End Class ' MySample

[C#] 
using System;
using System.Diagnostics;
              
class MySample{

    public static void Main(){

        EventLog myLog = new EventLog();
        myLog.Log = "MyNewLog";                      
        foreach(EventLogEntry entry in myLog.Entries){
            Console.WriteLine("\tEntry: " + entry.Message);
        }    
    }       
}
   

[C++] 
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;

int main(){

    EventLog* myLog = new EventLog();
    myLog->Log = S"MyNewLog";                      
    System::Collections::IEnumerator* myEnum = myLog->Entries->GetEnumerator();
    while (myEnum->MoveNext())
    {
        EventLogEntry* entry = __try_cast<EventLogEntry*>(myEnum->Current);
        Console::WriteLine(S"\tEntry: {0}", entry->Message);
    }    
}       

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

EventLogEntry Class | EventLogEntry Members | System.Diagnostics Namespace

Show: