当我将日志写入Windows事件日志时,我得到下面的事件,这条消息的根本原因是什么,我该如何解决?非常感谢
无法找到源RRWS的事件ID 51001的描述.引发此事件的组件未安装在本地计算机上,或者安装已损坏.您可以在本地计算机上安装或修复该组件.
如果事件源自另一台计算机,则必须随事件一起保存显示信息.
活动中包含以下信息:
测试日志消息
消息资源存在但在字符串/消息表中找不到该消息
我需要找到托管代码执行开始的程序集.
// using System.Reflection;
Assembly entryAssembly = Assembly.GetEntryAssembly();
Run Code Online (Sandbox Code Playgroud)
这似乎是要走的路,但MSDN参考页面Assembly.GetEntryAssembly说明这个方法"[c]从非托管代码调用时返回null."
在这种情况下,我想知道哪个程序集是由非托管代码调用的.
有没有可靠的方法来做到这一点,即总是返回非空Assembly引用?
我用C#开发了一个Windows服务.我用Visual Studio 2008创建了一个安装程序,它安装了Windows服务.到目前为止一切都很好.我想确保在安装时创建了事件源,以便运行时的任何错误/异常条件都正确记录到Windows事件日志中.
事件源是否作为Windows服务安装(和卸载)的一部分自动创建(和删除),或者我是否必须自己处理并创建自定义操作以创建和删除它,如下所示?
protected override void OnBeforeInstall(IDictionary savedState)
{
base.OnBeforeInstall(savedState);
if (!EventLog.SourceExists(ServiceName))
EventLog.CreateEventSource(ServiceName, "Application");
}
protected override void OnAfterUninstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
if (EventLog.SourceExists(ServiceName))
EventLog.DeleteEventSource(ServiceName);
}
Run Code Online (Sandbox Code Playgroud) 在我的C#应用程序中,我使用EventLog类来记录消息.它在我的机器上工作得非常好,但在客户端机器上并不真正有用.
客户端计算机配置与我的计算机不同.我的机器有Vista操作系统,而客户端有Windows 2003操作系统.
我在我的计算机上拥有管理员权限,而在客户端计算机上,我的应用程序在非管理员用户优先级下运行.
在客户端计算机上,我得到错误,因为Faulting应用程序,版本,错误模块kernel32.dll
当我注释掉EventLog.WriteEntry()方法调用并开始将日志写入简单文本文件时,我的应用程序停止在客户端计算机上崩溃.
所以我只是想知道事件记录是否需要管理员权限或什么?
环境细节:C#,.net 2.0框架,Windows Vista,Windows 2003服务器,Oracle
如何以编程方式检查/创建要在Windows XP/2003事件查看器中查看的自定义事件日志?
现在我可以在"应用程序"日志中创建条目,但希望为我的各种应用程序提供自定义日志.
我正在使用C# - .NET Framework 3.5
我正在尝试将我的.Net Windows服务转到自定义事件日志.我正在使用EventLogInstaller安装应用程序时创建事件日志和源.我在这里读到,Windows注册源需要一段时间,因此他们建议您在尝试写入日志之前重新启动应用程序.
由于这是Windows服务,我不想强制重新启动计算机或让用户手动启动服务,因此我使用此代码等待日志存在,然后自动启动服务.
while (!(EventLog.Exists("ManageIT") || EventLog.SourceExists("ManageIT Client Service")))
{
Thread.Sleep(1000);
}
System.ServiceProcess.ServiceController controller = new System.ServiceProcess.ServiceController("ManageIT.Client.Service");
controller.Start();
Run Code Online (Sandbox Code Playgroud)
我的问题是来自服务的事件仍然写入应用程序日志,虽然我可以在注册表编辑器中看到我的自定义日志,但它不会显示在Windows 7事件查看器中.
任何帮助都感激不尽.
我创建了一个 Windows 服务。我创建一个事件日志。
public Service1()
{
InitializeComponent();
this.ServiceName = ConfigurationManager.AppSettings.Get("ServiceName");
string sourceName = ConfigurationManager.AppSettings.Get("ServiceName");
string logName = ConfigurationManager.AppSettings["EventLogName"];
try
{
if (!System.Diagnostics.EventLog.Exists(sourceName))
System.Diagnostics.EventLog.CreateEventSource(sourceName, logName);
eventLog.Source = sourceName;
eventLog.Log = logName;
}
catch
{
eventLog.Source = "Application";
}
}
Run Code Online (Sandbox Code Playgroud)
初始化期间,会安装服务但不会创建日志。日志条目位于Application系统日志中。
我错过了什么?
我使用进程安装程序进行安装
public ProjectInstaller()
{
InitializeComponent();
this.Installers.Add(GetServiceInstaller());
this.Installers.Add(GetServiceProcessInstaller());
}
private ServiceInstaller GetServiceInstaller()
{
serviceInstaller.ServiceName = GetConfigurationValue("ServiceName");
serviceInstaller.Description = GetConfigurationValue("Description");
serviceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
return serviceInstaller;
}
private ServiceProcessInstaller GetServiceProcessInstaller()
{
serviceProcessinstaller.Account = ServiceAccount.LocalSystem;
return serviceProcessinstaller;
}
Run Code Online (Sandbox Code Playgroud)
如何创建事件日志?