Easier way to debug a Windows service

后端 未结 28 2077
春和景丽
春和景丽 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:23

    Just put your debugger lunch anywhere and attach Visualstudio on startup

    #if DEBUG
        Debugger.Launch();
    #endif
    

    Also you need to start VS as Administatrator and you need to allow, that a process can automatically be debugged by a diffrent user (as explained here):

    reg add "HKCR\AppID{E62A7A31-6025-408E-87F6-81AEB0DC9347}" /v AppIDFlags /t REG_DWORD /d 8 /f
    

提交回复
热议问题