为什么 EventRecord.FormatDescription() 返回 null?
使用 System.Diagnostics.Eventing.Reader.EventLogQuery 从 Windows 事件日志读取事件时,EventRecord.FormatDescription() 方法有时会返回 null。这是为什么呢?在事件查看器中,有有关返回 null 的事件的消息。
When using System.Diagnostics.Eventing.Reader.EventLogQuery
to read events from the Windows Event Log, the EventRecord.FormatDescription()
method sometimes returns null. Why is this? In the Event Viewer there are messages on the events which return null.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是由于 .NET 框架中的错误造成的。
基本上,要解决此错误,您需要做的就是将 CurrentCulture 设置为“en-US”。
示例:
这个解决方法
is很难找到,所以我想我应该将其记录在一个将被Google索引的地方。我在旧的 MS Connect 中找到了它案例,但已关闭,状态为“无法修复”。更新:
该错误已报告对于 .NET 4 也是如此,状态为“发送给工程团队考虑”,并评论暗示该错误可能会在下一个主要 .NET 框架版本 (v5) 中得到修复。
This is due to a bug in the .NET framework.
Basically what you need to do to work around this bug is to set the CurrentCulture to "en-US".
Example:
This workaround
iswas very hard to find, so I thought I would document it a place where it will be indexed by Google. I found it in an old MS Connect case, but it has been closed with a status of "wont fix".UPDATE:
The bug has been reported for .NET 4 as well and the status is "Sent to Engineering Team for consideration" and comment alluding that the bug might be fixed in the next major .NET framework release (v5).
所以我也为此苦苦挣扎了几天。我无法通过改变文化来让它发挥作用。最后,我只是使用了事件记录的 Properties 属性中的原始数据。消息数据就在那里,只是不太漂亮。 (不过足以满足我的审计需求:-))
so i've been struggling with this for a few days too. I couldn't get it to work by changing the culture. In the end, i just used the raw data in the Properties property of the event record. The message data is in there, it's just not pretty. (just about good enough for my audit needs though :-))