加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 为什么限制参数类型和对EventSource方法的计数

发布时间:2020-12-15 18:02:57 所属栏目:百科 来源:网络整理
导读:我现在正在用C#中的Microsoft EventSources进行实验. 一个限制如下 …The number and types of arguments passed to the ETW method must exactly match the types passed to the WriteEvent overload it calls. For example: [Event(2,Level = EventLevel.I
我现在正在用C#中的Microsoft EventSources进行实验.
一个限制如下

…The number and types of arguments passed to the ETW method must
exactly match the types passed to the WriteEvent overload it calls.
For example:

[Event(2,Level = EventLevel.Informational)] 
public void Info(string message,int count) 
{
   base.WriteEvent(2,message,count); 
}

这基本上限制了您在EventSource类中编写更丰富的API.这基本上意味着您无法创建接收自定义对象的方法,并且在方法体内可以将其序列化为字符串(或WriteEvent重载支持的其他类型).

您唯一能决定的是方法名称以及反映WriteEvent重载的参数名称和计数.
还是我错了?

解决方法

这是构建清单文件所必需的. The_EventSourceUsersGuide.docx解释了它:

Event methods must match exactly the types of the WriteEvent overload it calls,in particular you should avoid implicit scalar conversions; they are dangerous because the manifest is generated based on the signature of the ETW event method,but the values passed to ETW are based on the signature of the WriteEvent overload.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读