3

I have a demo solution which raises events by using System.Diagnostics.Tracing.EventSource class. The class I have is as below:-

[EventSource(Guid = "B6741490-9F53-4620-A45C-49004C1B4444", Name = "DemoEvent")]
sealed public class DemoEventSource : EventSource
{
    [Event(1, Level = EventLevel.LogAlways, Keywords = EventKeywords.None)]
    public void RaiseEvent()
    {
        this.WriteEvent(1, "Found");
    }
}

I followed the steps given here to use PerfView tool to view the events being generated by this solution. I have given *DemoEvent in the additionalProvider section of the PerfView. However, I am not able to see these events in the output of PerfView. Can anyone help me here?

AvinashK
  • 3,309
  • 8
  • 43
  • 94

1 Answers1

2

The argument types of your method and argument types of your call to write event must match (adding one integer first argument as you have for the event id) so the auto-generated event source metadata match. i.e.

[Event(1, Level = EventLevel.LogAlways, Keywords = EventKeywords.None)]
public void RaiseEvent(string message)
{
    this.WriteEvent(1, message);
}

Avoid providing a GUID. It is recommended in the Event Source programming guide from the .NET authors that you only provide the name and let the GUID be automatically generated from the name.

Make sure you are using the latest PerfView release from GitHub rather than the obsolete version on Microsoft Downloads.

David Burg
  • 1,064
  • 12
  • 14