Windows服务不执行OnStart入口点

时间:2013-10-16 17:45:50

标签: c# visual-studio-2012 windows-services

我安装了一个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);

我在Service中检查过,“Some”正在服务中正常运行。 我不知道如何初始化,以便我可以在WindowsService中访问受保护的OnStart()函数,以便它可以调用OnStart()函数中的函数。

任何想法都表示赞赏。非常感谢。 :)

1 个答案:

答案 0 :(得分:1)

您可以测试此方法的一种方法是编写日志文件或windows event log

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