Export (0) Print
Expand All

EventSource.WriteEvent Method (Int32)

.NET Framework 4.5

Writes an event by using the provided event identifier.

Namespace:  System.Diagnostics.Tracing
Assembly:  mscorlib (in mscorlib.dll)

protected void WriteEvent(
	int eventId
)

Parameters

eventId
Type: System.Int32

The event identifier. This value should be between 0 and 65535.

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
 base.WriteEvent(2, arg1);
}

The following example shows how to use this method overload to write an event. This code example is part of a larger example provided for the EventSource class.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft