How do I debug Windows services in Visual Studio?

后端 未结 17 779
梦毁少年i
梦毁少年i 2020-11-28 03:56

Is it possible to debug the Windows services in Visual Studio?

I used code like

System.Diagnostics.Debugger.Break();

but it is givi

17条回答
  •  臣服心动
    2020-11-28 04:28

    I use a great Nuget package called ServiceProcess.Helpers.

    And I quote...

    It helps windows services debugging by creating a play/stop/pause UI when running with a debugger attached, but also allows the service to be installed and run by the windows server environment.

    All this with one line of code.

    http://windowsservicehelper.codeplex.com/

    Once installed and wired in all you need to do is set your windows service project as the start-up project and click start on your debugger.

提交回复
热议问题