How do you debug a Windows Service?

后端 未结 15 2842
春和景丽
春和景丽 2020-12-12 21:07

I read the MSDN article on the topic. To quote:

Because a service must be run from within the context of the Services Control Manager rather than

15条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 21:53

    I usually just manually set a breakpoint, then point it to the currently open project in c#. The code to set a breakpoint is:

    System.Diagnostics.Debugger.Break();
    

    That should get you started, then you can just step through your code and see what's really happening.

提交回复
热议问题