Click here to Skip to main content
16,015,296 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I am somewhat new to C# programming, and have a very basic question.
In most debuggers/emulators I am familiar with, when the code is running
and you "break" the debugger, the debugger usually shows you exactly where
the code was running.

This does not seem to be the case when I do this for my Windows service.
It always takes me back to an early point:

ServiceBase.Run(ServicesToRun);

Is there any way to see the stack and/or the exact instruction (preferably
source code line) where it is running when I break?

Thanks,

Mitch
Posted

Yes there is a view stack option.

Here[^] is more information on this window.
 
Share this answer
 
Comments
mitchmcc 26-Jul-11 11:06am    
When I "break all", the call stack shows the same place I mentioned in my original post, which is not really where the program is running (I know it is always busy, and expect to see where in the main program logic it is).
If the process is in a message loop wait state, you will often get a useless breakpoint like this (or Application.Run in WinForms apps). If the service is not really doing anything on its primary thread (and a service is not most of the time), breaking it will do this. Put a breakpoint in some functional code if you want to get a stop in a useful place.
 
Share this answer
 
Comments
mitchmcc 26-Jul-11 11:08am    
I know I can put in a breakpoint and get it to stop somewhere useful, but in this instance, I knew (or at least suspected) that it was blocked inside a MessageQueue.Receive() call, but the "break all" does NOT show this in the call stack trace, as I would have expected.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900