EventSource.WriteEvent Method

.NET Framework 4.5

Writes an event by using the provided event identifier and optional arguments.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Protected method WriteEvent(Int32) Writes an event by using the provided event identifier.
Protected method WriteEvent(Int32, Int32) Writes an event by using the provided event identifier and 32-bit integer argument.
Protected method WriteEvent(Int32, Int64) Writes an event by using the provided event identifier and 64-bit integer argument.
Protected method WriteEvent(Int32, Object[]) Writes an event by using the provided event identifier and array of arguments.
Protected method WriteEvent(Int32, String) Writes an event by using the provided event identifier and string argument.
Protected method WriteEvent(Int32, Int32, Int32) Writes an event by using the provided event identifier and 32-bit integer arguments.
Protected method WriteEvent(Int32, Int64, Int64) Writes an event by using the provided event identifier and 64-bit arguments.
Protected method WriteEvent(Int32, String, Int32) Writes an event by using the provided event identifier and arguments.
Protected method WriteEvent(Int32, String, Int64) Writes an event by using the provided event identifier and arguments.
Protected method WriteEvent(Int32, String, String) Writes an event by using the provided event identifier and string arguments.
Protected method WriteEvent(Int32, Int32, Int32, Int32) Writes an event by using the provided event identifier and 32-bit integer arguments.
Protected method WriteEvent(Int32, Int64, Int64, Int64) Writes an event by using the provided event identifier and 64-bit arguments.
Protected method WriteEvent(Int32, String, Int32, Int32) Writes an event by using the provided event identifier and arguments.
Protected method WriteEvent(Int32, String, String, String) Writes an event by using the provided event identifier and string arguments.
Top

The WriteEvent method provides overloads with combinations of string and integer arguments. If none of these combinations match the parameters for the call, the compiler uses the EventSource.WriteEvent(Int32, Object[]) overload, which is considerably slower than the other overloads. See the overload page for details.

In all cases, the eventid parameter 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);
}

You can also create a custom overload by using the WriteEventCore method.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft