3

I cant seem to debug a recent modified windows service. When I first installed it, I was able to debug it by attaching the debugger to this running service (eg using 'Attach to process' in visual studio).

However, recently I have modified the service code, rebuilt it and reinstalled it. Now I cant seem to debug it - it says that 'The breakpoint will not be currently hit'.

I hope I have provided enough info. Many thanks.

skub
  • 2,266
  • 23
  • 33
  • 1
    Bring up the modules window and check the pdb files are loaded – Jeremy Thompson Aug 23 '12 at 01:49
  • hmm ... I cant see any pdb files, only dlls. How do I go about resolving this - thanks? – skub Aug 23 '12 at 01:57
  • Assuming you built in debug mode, you have the pdb files - it's probably just that the installer does not include then. You can manually copy them to the same directory the service is running from. – James Aug 23 '12 at 02:00

3 Answers3

6

Or you could specify the path to your Symbols for Visual Studio to find.

Tools > Options > Debugging > Symbols > Add in the directory of your pdb files.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • 1
    Thanks for that, but now there is a message saying that 'PDB does not match image' – skub Aug 23 '12 at 02:13
  • Sounds like you need recompile the application to make the PDB files match the image. – Jeremy Thompson Aug 23 '12 at 02:37
  • 1
    ok all good now! Many thanks for this - you're a life saver :) – skub Aug 23 '12 at 03:26
  • It's infuriating because somehow old versions of binaries can be executed. I have copied a new DLL and PDB pair into the target from my VS machine and the debugger when attached still says the PDB and DLL don't match. The code executed is also provably the old version. When checking Process Explorer .NET assemblies the correct file path is referenced but I have no doubt the wrong code is being run - the old code is. It's like there is a cache somewhere. – Shiv Oct 09 '19 at 00:28
  • @Shiv go through the canonical QA and follow everyone's advice: https://stackoverflow.com/questions/2155930/how-do-i-remedy-the-the-breakpoint-will-not-currently-be-hit-no-symbols-have-b – Jeremy Thompson Oct 09 '19 at 00:39
  • @JeremyThompson I'm implying the advice here doesn't make sense. The symbol matching doesn't always work. The dev environment has undocumented "features" that prevent things working predictably. – Shiv Oct 09 '19 at 00:46
  • @Shiv are you saying my advice doesn't make sense? *When checking Process Explorer .NET assemblies the correct file path is referenced* - that's not the correct way to check the correct versions using file paths, you do it using the Windows > Debug > Modules. – Jeremy Thompson Oct 09 '19 at 00:48
1

Make sure that you are using the latest update of your assembly .. in my case the installUtil.exe keeps installing an older version of my windows service.

the resolve was :

(1) uninstall the service

(2) delete all files in bin/Debug folder then rebuild the project

(3) install service again

then the debug worked just fine

Community
  • 1
  • 1
Mawardy
  • 3,618
  • 2
  • 33
  • 37
0

Uninstall the service and build it in debug mode and reinstall it. Note: Make sure that you switched to debug configuration while attaching to process.

Sneha
  • 428
  • 4
  • 10