Starting a windows service fails with error 1053

后端 未结 10 1396
逝去的感伤
逝去的感伤 2020-12-10 13:41

I have a windows service that is failing to start, giving an error \"Error 1053: The service did not respond to the start or control request in a timely fashion\".

10条回答
  •  臣服心动
    2020-12-10 14:11

    This is a misleading error. It's probably an unhandled exception.

    Empty your OnStart() handler then try this in your constructor...

        public MainService()
        {
            InitializeComponent();
    
            try
            {
                // All your initialization code goes here.
    
                // For instance, my exception was caused by the lack of registry permissions
                ;
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
            }
        }
    

    Now check the EventLog on your system for your Application Error.

提交回复
热议问题