Debugging a service in .NET
To debug a service in .NET, put
System.Diagnostics.Debugger.Break();
in the OnStart method. This will fire up a prompt when run, which is where the debugger can be selected.
System.Diagnostics.Debugger.Break();
in the OnStart method. This will fire up a prompt when run, which is where the debugger can be selected.
3 Comments:
I'm trying this, with no luck. The debugger prompt comes up, and I select the running instance of VS2005, which is made the foreground task, but the "breakpoint" is not hit. Any other special considerations I need to know about?
Not that I'm aware of. Unfortunately I'm not an expert - I found out about it from a Google search, tried it and it just worked. If it's just an example you're trying, could you zip it up and send it to me?
Ah, worked it out: you have to put a manual breakpoint on the next line of code.
Post a Comment