我正在维护一个Windows服务,它有一个相当不幸的错误。我不能再调试代码,因为服务只是拒绝启动。这是错误:我的Windows服务无法实例化
Windows could not start the MyService service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
我插入一些日志到文件的线路中的主要方法,它从来没有谈到过了我的Windows服务的实例。它在行之前停止
ServiceBase.Run(ServicesToRun);
因此Run方法从不执行。我猜测这是MyService的实例化失败。但这怎么可能?
static void Main()
{
//this line is reached
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MyService() //halts here
};
//this line is never executed
ServiceBase.Run(ServicesToRun);
}
您可以将代码发布在MyService构造函数中吗? – w69rdy
“MyService”的构造函数是什么样的? –
您是否在事件查看器中有更多信息?还要确保您正在运行该服务的帐户具有足够的权限。 –