How to debug the .NET Windows Service OnStart method?

后端 未结 16 1318
离开以前
离开以前 2020-12-01 00:13

I have code written in .NET that only fails when installed as a Windows service. The failure doesn\'t allow the service to even start. I can\'t figure out how I can step int

16条回答
  •  忘掉有多难
    2020-12-01 00:33

    The options above did not appear to work on Windows 8.

    I have added Thread.Sleep(15000); into my OnStart() method and set a breakpoint on the next line of the code. This give me 15 seconds to attach VS debugger to my process after starting the service and allowed me to debug the OnStart() method nicely.

提交回复
热议问题