我试图按照这个演练.
我正在使用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)