Pages

Monday, April 8, 2013

Force your executable into debug mode with the Stop command

You’ve probably placed physical breakpoints in code while debugging hundreds of times. However, you may not be aware that you can programmatically do the same for your executables with the Stop command. This statement is most useful when you’re trying to debug applications that don’t have a visual interface or that generate an error only when you run the executable.

To programmatically add a breakpoint, simply place the Stop command at the point in your code you want to monitor. Then build and run your executable as you normally would. Now, when you execute your code and it reaches the Stop command, the application halts, the .NET debugger launches, and after you answer a few questions, the debugger attaches to your process (just as if you’d used the Debug Processes feature in the VS .NET IDE).

You can even place the Stop command in ASP.NET applications. However, if your browser doesn’t allow debugging, the debugger won’t launch.



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.