&“无法找到源 Y 中事件 ID X 的描述." [英] "The description for Event ID X in Source Y cannot be found."

查看:28
本文介绍了&“无法找到源 Y 中事件 ID X 的描述."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Web 应用程序中的自定义事件写入 Windows 事件日志.我没有让消息字符串正常工作,我一直收到找不到源 Y 中事件 ID X 的描述."

I'm trying to write custom events from my web application to the windows event log. I've had no luck getting the message strings to work, I keep getting "The description for Event ID X in Source Y cannot be found."

为了缩小范围,我决定将事件写出到我机器上已经存在的源.我只是查看了已经写出的事件之一,特别是 SceCli 事件 1704.

In trying to narrow this down I decided to write out an event to a source that already exists on my machine. I just looked at one of the events that was already written out, specifically SceCli event 1704.

我执行以下代码:

var log = new EventLog("Application");
log.Source = "SceCli";

var ev = new EventInstance(1704, 0, EventLogEntryType.Information);
log.WriteEvent(ev);

但是,这仍然在事件查看器中为我提供以下内容:

However, this still gives me the following in Event Viewer:

找不到源 (SceCli) 中事件 ID (1704) 的描述.本地计算机可能没有必要的注册表信息或消息 DLL 文件来显示来自远程计算机的消息.您可以使用/AUXSOURCE= 标志来检索此描述;有关详细信息,请参阅帮助和支持.以下信息是事件的一部分:事件日志文件已损坏..

The description for Event ID ( 1704 ) in Source ( SceCli ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: The event log file is corrupt..

我不确定我在这里遗漏了什么.我正在写出已经存在的完全相同的事件,但它仍然找不到消息字符串.

I'm not sure what I'm missing here. I'm writing out the exact same event that already exists, and it still can't find the message string.

推荐答案

我也遇到过类似的问题.在做了大量研究之后,我按照这篇文章验证了步骤 http://www.codeproject.com/Articles/4166/Using-MC-exe-message-resources-and-the-NT-event-lo 一切似乎到位.除了一件事......当我偶然发现这个 msdn http://msdn.microsoft.com/en-us/library/windows/desktop/aa363661(v=vs.85).aspx

I also faced similar problem. After doing lot of research I did following I verified the steps according to this article http://www.codeproject.com/Articles/4166/Using-MC-exe-message-resources-and-the-NT-event-lo Everything seemed to be in place. Except one thing..i realised it when I stumbled on this msdn http://msdn.microsoft.com/en-us/library/windows/desktop/aa363661(v=vs.85).aspx

如最后一段所述.. '如果应用程序调用 RegisterEventSource 并传递在注册表中找不到的源名称,则事件记录服务默认使用应用程序日志.但是,由于没有消息文件,事件查看器无法将任何事件标识符或事件类别映射到描述字符串,并且会显示错误.出于这个原因,您应该为您的应用程序向注册表添加一个唯一的事件源并指定一个消息文件.所以我在 RegisterEventSource 中的应用程序名称与注册表中的应用程序名称不匹配.我解决了这个问题,现在它可以工作了......所以如果你遇到这个问题,请仔细检查你的注册表项.

As last paragraph says.. 'If the application calls RegisterEventSource and passes a source name that cannot be found in the registry, the event-logging service uses the Application log by default. However, because there are no message files, the Event Viewer cannot map any event identifiers or event categories to a description string, and will display an error. For this reason, you should add a unique event source to the registry for your application and specify a message file.' So my application name in RegisterEventSource was not matching with the application name in registry. I fixed this and now it works... So please double check your registry entries if you face this problem.

这篇关于&“无法找到源 Y 中事件 ID X 的描述."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆