【发布时间】:2011-11-24 00:16:05
【问题描述】:
我正在尝试关注这个walkthrough。
我使用的是 Visual Studio 2010 Premium。
我在服务器资源管理器或事件查看器中看到的唯一事件是“服务已成功启动”。和“服务已成功停止。”
这里是服务代码:
namespace MyNewService
{
public partial class MyNewService : ServiceBase
{
public MyNewService()
{
InitializeComponent();
if (!EventLog.SourceExists("MySource"))
{
EventLog.CreateEventSource("MySource", "MyNewLog");
}
eventLog1.Source = "MySource";
eventLog1.Log = "MyNewLog";
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
}
protected override void OnStop()
{
eventLog1.WriteEntry("In onStop.");
}
}
}
【问题讨论】:
-
您看到自己的事件日志出现还是正在查看应用程序日志?
-
以管理员身份运行开发环境(右键单击,以管理员身份运行...)这可能是权限问题。
-
我以管理员身份启动了 VS,并且得到了输出。
标签: c# windows windows-services event-log windows-7-x64