Windows 服务未执行 OnStart 入口点

本文关键字:入口 OnStart 执行 服务 Windows | 更新日期: 2023-09-27 18:35:35

我安装了Windows服务,

Some.WindowsService wService = new WindowsService();
Some.Server server = new Server();
Some.Service service = new Service();
Some.Request request = new Some.Request(msg, Id);
var ReturnedResult = server.Execute(request);

我签入了服务,"一些"在服务中正常运行。我不知道如何初始化以便我可以访问WindowsService中受保护的OnStart()函数,以便它可以调用OnStart()函数中的函数。

任何想法都值得赞赏。多谢。: )

Windows 服务未执行 OnStart 入口点

测试这一点的一种方法是写入日志文件或 Windows 事件日志

System.Diagnostics.EventLog appLog = 
    new System.Diagnostics.EventLog() ;
appLog.Source = "This Application's Name";
appLog.WriteEntry("An entry to the Application event log.");