Semantic Logging Analyzer exception number of WriteEvent arguments and event parameters are different

361 Views Asked by At

This fragment makes the Semantic Log Analyzer throw "The number of WriteEvent arguments and event parameters are different in event name 'HandlingCommand'."

[NonEvent]
public void HandlingCommand(Command command)
{
    if (this.IsEnabled())
    {
        this.HandlingCommand(command.Id.ToString(), command.Agent.AgentId.ToString());
    }
}

[Event(1101,
    Level = EventLevel.Informational,
    Keywords = Keywords.Agent)]
private void HandlingCommand(string commandId, string agentId)
{
    this.WriteEvent(1101, commandId, agentId);
}

The only way to resolve the analyzer error is to have two WriteEvent parameters (event id and commandId for example) and one event argument (commandId for example). If I try with any combination with more than one parameter/argument the above mentioned exception is thrown. The exception is thrown on any event with more than one parameter/argument not just the supplied example.

I have used these samples as a starting point https://github.com/mspnp/semantic-logging/tree/master/quickstarts.

1

There are 1 best solutions below

0
On

I ran into the same error and couldn't figure it out. Eventually I got the EventSourceAnalyzer code, compiled and debugged.

What I found was that my WriteEvent was actually writing the following:
EventSourceException while processing event "MethodName": No Free Buffers available from the operating system (e.g. event rate too fast).

in the EventSourceAnalyzer class there is this line:
if (eventParameters.Length != this.EventData.Payload.Count)
throw mismatch exception

Now, because my WriteEvent was actually passing in 3 params, the fact that the WriteEvent was in essence throwing an error caused the EventSourceAnalyzer to incorrectly interpret it as a mismatch.