小编fee*_*nst的帖子

Windows服务输出未显示在事件日志中

我试图按照这个演练.

我正在使用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.");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# windows windows-services event-log windows-7-x64

6
推荐指数
1
解决办法
3375
查看次数

标签 统计

c# ×1

event-log ×1

windows ×1

windows-7-x64 ×1

windows-services ×1