我有一个演示解决方案,通过使用System.Diagnostics.Tracing.EventSource类引发事件。我的课程如下:
[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");
}
}我按照给定here的步骤使用PerfView工具查看此解决方案生成的事件。我已经在PerfView的additionalProvider部分给了*DemoEvent。但是,我无法在PerfView的输出中看到这些事件。有人能帮我吗?
发布于 2018-05-03 03:19:28
方法的参数类型和对write event的调用的参数类型必须匹配(添加一个整数第一个参数,就像您为事件id所做的那样),以便自动生成的事件源元数据匹配。即
Event(1,Level = EventLevel.LogAlways,Keywords = EventKeywords.None)公共空消息(String RaiseEvent){ this.WriteEvent(1,message);}
避免提供GUID。在the Event Source programming guide from the .NET authors中,建议您仅提供名称,并根据名称自动生成GUID。
确保您使用的是the latest PerfView release from GitHub,而不是微软下载上的过时版本。
https://stackoverflow.com/questions/38766604
复制相似问题