Easier way to debug a Windows service

后端 未结 28 1937
春和景丽
春和景丽 2020-11-22 15:36

Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It\'s ki

28条回答
  •  不要未来只要你来
    2020-11-22 16:10

    When I write a service I put all the service logic in a dll project and create two "hosts" that call into this dll, one is a Windows service and the other is a command line application.

    I use the command line application for debugging and attach the debugger to the real service only for bugs I can't reproduce in the command line application.

    I you use this approach just remember that you have to test all the code while running in a real service, while the command line tool is a nice debugging aid it's a different environment and it doesn't behave exactly like a real service.

提交回复
热议问题