Error 1053: the service did not respond to the start or control request in a timely fashion

后端 未结 30 1196
無奈伤痛
無奈伤痛 2020-11-29 18:47

I have recently inherited a couple of applications that run as windows services, and I am having problems providing a gui (accessible from a context menu in system tray) wit

30条回答
  •  醉梦人生
    2020-11-29 19:30

    To debug the startup of your service, add the following to the top of the OnStart() method of your service:

     while(!System.Diagnostics.Debugger.IsAttached) Thread.Sleep(100);
    

    This will stall the service until you manually attach the Visual Studio Debugger using Debug -> Attach to Process...

    Note: In general, if you need a user to interact with your service, it is better to split the GUI components into a separate Windows application that runs when the user logs in. You then use something like named pipes or some other form of IPC to establish communication between the GUI app and your service. This is in fact the only way that this is possible in Windows Vista.

提交回复
热议问题