TraceContextRecord.Message Eigenschaft

Definition

Ruft die benutzerdefinierte Ablaufverfolgungsmeldung ab.Gets the user-defined trace message.

public:
 property System::String ^ Message { System::String ^ get(); };
public string Message { get; }
member this.Message : string
Public ReadOnly Property Message As String

Eigenschaftswert

Eine Zeichenfolge, die eine Meldung für den Ablaufverfolgungsdatensatz darstellt.A string that represents a message for the trace record.

Beispiele

Im folgenden Codebeispiel Message TraceContextRecordwird veranschaulicht, wie auf die-Eigenschaft eines zugegriffen und in den Response Stream gedruckt wird.The following code example demonstrates how to access the Message property of a TraceContextRecord, and print it to the Response stream.

<%@ Page language="c#" Trace="true" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
    // Register a handler for the TraceFinished event.
    Trace.TraceFinished += new 
        TraceContextEventHandler(this.OnTraceFinished);

    try {
        throw new ArgumentException("Trace Test");
    }
    catch (InvalidOperationException ioe) {    
        // You can write an error trace message using the Write method.
        Trace.Write("Exception Handling", "Exception: Page_Load.", ioe);
    }
    catch (ArgumentException ae) {    
        // You can write a warning trace message using the Warn method.
        Trace.Warn("Exception Handling", "Warning: Page_Load.", ae);
    }
}
 
// A TraceContextEventHandler for the TraceFinished event.
void OnTraceFinished(object sender, TraceContextEventArgs e)
{
    TraceContextRecord r = null;    
    
    // Iterate through the collection of trace records and write 
    // them to the response stream.
    foreach(object o in e.TraceRecords)
    { 
        r = (TraceContextRecord)o;
        if (r.IsWarning) {
            Response.Write(String.Format("warning message: {0} <BR>", r.Message));
        }
        else {
            Response.Write(String.Format("error message: {0} <BR>", r.Message));
        }

    }
}       
</script>
<%@ Page language="VB" Trace="true" %>
<script runat="server">
' The Page_Load method.
Private Sub Page_Load(sender As Object, e As EventArgs)

    ' Register a handler for the TraceFinished event.
    AddHandler Trace.TraceFinished, AddressOf OnTraceFinished

    Try 
    Dim ae As New ArgumentException("Trace Test")
        Throw ae
    
    catch ioe As InvalidOperationException
        ' You can write an error trace message using the Write method.
        Trace.Write("Exception Handling", "Exception: Page_Load.", ioe)
    
    Catch ae As ArgumentException
        ' You can write a warning trace message using the Warn method.
        Trace.Warn("Exception Handling", "Warning: Page_Load.", ae)

    End Try

End Sub ' Page_Load
 
' A TraceContextEventHandler for the TraceFinished event.
Private Sub OnTraceFinished(sender As Object, e As TraceContextEventArgs)

    Dim r As TraceContextRecord
    Dim o As Object
    
    ' Iterate through the collection of trace records and write 
    ' them to the response stream.

    For Each o In e.TraceRecords
        r = CType(o, TraceContextRecord)
    If r.IsWarning Then
            Response.Write(String.Format("warning message: {0} <BR>", r.Message))
        Else
            Response.Write(String.Format("error message: {0} <BR>", r.Message))
        End If
    Next

End Sub	' OnTraceFinished
</script>

Hinweise

Die Nachricht kann eine beliebige Zeichenfolge sein und wird verwendet, um ausführliche Ablauf Verfolgungs Informationen zu schreiben.The message can be any string, and is used to write detailed tracing information. Sie entspricht dem Message-Parameter, der an die- TraceContext.Write Methode TraceContext.Warn und die-Methode übergeben wird.It corresponds to the message parameter that is passed to the TraceContext.Write and TraceContext.Warn methods. Dabei kann es sich um Lauf Zeit Werte, Meldungen zur Orientierung und durch die Ausführung eines Programms oder andere Diagnosedaten handeln.The information can be run-time values, messages to orient you and guide you through a program's execution, or other diagnostic data.

Gilt für:

Siehe auch