VS2008 on Win7 64-Bit: Debugging a Windows Service

前端 未结 3 414
旧巷少年郎
旧巷少年郎 2021-01-21 02:44

I\'m trying to debug a Windows Service using VS2008 on Win7 64-Bit. The problem I\'m having is that none of my breakpoints are being hit, regardless of which build configuration

3条回答
  •  萌比男神i
    2021-01-21 03:05

    Obvious questions first...

    • Are you compiling in debug mode or release mode?
    • Are the .pdb files located where your service is installed from?
    • Are you sure the code where your breakpoints are set is actually being executed?

    If none of these are issues, try inserting the following line in the constructor for your service.

    System.Diagnostics.Debugger.Break();
    

    When the service starts up, you should be prompted to choose a debugger. When the debugger opens, it'll pause at the programmatic breakpoint, and you can continue from there. I don't work with Windows 7, but I don't expect this aspect of Visual Studio 2008 has changed much from Windows XP. I use this programmatic method all the time to enter a debug session for my Windows service.

提交回复
热议问题