EventSource.WriteEvent Method (Int32, Object[]) not working

Topics: Semantic Logging Application Block
Jul 16, 2013 at 8:20 PM
Error: Unsupported type Object[] in event source

I cannot get this overload of the WriteEvent Method to work:
EventSource.WriteEvent Method (Int32, Object[])

According to this link, it should work:

Here is the code I am using
public class Logger : EventSource
    public static readonly Logger Log = new Logger();

    [Event(101, Level = EventLevel.Informational]
    public void TestObjectParms(params object[] args)
        if (IsEnabled()) WriteEvent(101, args);
To invoke:
object[] testArgs = {"object1","object2","object3"};
It compiles clean but the EventSourceAnalyzer returns this message:
"Error: Unsupported type Object[] in event source"

My other events all work fine. Any help would be appreciated.
Jul 16, 2013 at 9:16 PM
Only certain parameter types are supported by the System.Diagnostics.Tracing.EventSource infrastructure as parameters for an EventSource Event method. As the error mentions Object[] is not one of these types. This constraint is on the Event method, TestObjectParms, and not related to WriteEvent . The link you referenced is for the internal EventSource.WriteEvent method which does take params.

This makes sense because Semantic logging is about structured data; the infrastructure interrogates the method signatures of the public EventSource methods (e.g. TestObjectParms) to create a manifest which describes the event metadata (e.g. parameter types, parameter order, OpCodes, etc.). The metadata is used in reading and writing the event data so that structure is maintained (among other things).

Randy Levy
Enterprise Library support engineer
Support How-to
Marked as answer by randylevy on 10/7/2013 at 11:09 PM
Jul 16, 2013 at 9:50 PM
Ok, thank you. The internal EventSource.WriteEvent method is what was throwing me off.