WriteEvent Method (EventDescriptor, Object[])

EventProvider.WriteEvent Method (EventDescriptor, Object[])


Writes an event. The event data is specified as an array of objects.

Namespace:   System.Diagnostics.Eventing
Assembly:  System.Core (in System.Core.dll)

public bool WriteEvent(
	ref EventDescriptor eventDescriptor,
	params object[] eventPayload


Type: System.Diagnostics.Eventing.EventDescriptor

An instance of EventDescriptor that identifies the event to write.

Type: System.Object[]

An array of objects that contain the event data to write. The object must be in the order specified in the manifest. The array is limited to 32 objects, of which only eight may be strings. The maximum data size for the event is limited to 64 KB minus the size of the event headers. The event size is less if the session's buffer size is less and the session includes extended data items with the event.

This parameter can be null.

Return Value

Type: System.Boolean

Is true if the event is written; otherwise, false. If false, call the EventProvider.GetLastWriteEventError method to determine the cause of the failure.

Exception Condition

The eventPayload parameter contains too many objects or strings.

If you call the SetActivityId method to specify an activity identifier for the event, this method retrieves the identifier from the thread context and includes it with the event.

If the object type is not supported, the method writes the value of the object's Object.ToString method in the payload. For a list of supported object types, see the Remarks for the EventProvider class.

private static Guid providerId = new Guid("{FB33FDA8-45FB-4df0-8A55-EEB4BA88E7E7}");

enum Keyword
    Read = 0x1,
    Write = 0x2,
    Local = 0x4,
    Remote = 0x8

enum Level
    Critical = 1,

    EventProvider provider = new EventProvider(providerId);
    EventDescriptor readEvent;
    string path = @"<PATHGOESHERE>";
    UInt64 bytesRead = <ASSIGNVALUE>;

    if (provider.IsEnabled(Level.Information, (long)Keyword.Read))
            readEvent = new EventDescriptor(0x1, 0x0, 0x10, 0x4, 0x0, 0x0, (long)0x8000000000000005);

        if (!provider.WriteEvent(ref readEvent, new object[] { path, bytesRead }))


.NET Framework
Available since 3.5
Return to top
© 2015 Microsoft