How to: Step Into Just My Code
Sometimes, while debugging, you may want to look at only the code you have written and ignore other code such as system calls. You can do this with Just My Code debugging. Just My Code hides non-user code so that it does not appear in the debugger windows. When you step, the debugger steps through any non-user code but does not stop in it.
To distinguish user code ("My Code") from non-user code, Just My Code looks at three things: DBG Files, PDB files, and optimization.
In a standard Debug build, optimization is turned off and debug symbols are created for all modules. When I run a debug build, those modules are considered to be My Code. If I call a library function that is optimized and does not have debug symbols, however, it is not My Code. Just My Code prevents me from stopping in the library code, which is the behavior I want in most cases.
Sometimes, however, you may need to see code that is hidden by Just My Code debugging. When that happens, you can turn Just My Code off using the Options dialog box.
The definition of My Code is also affected by three attributes. DebuggerNonUserCodeAttribute tells the debugger that the code it is applied to should not be considered My Code. DebuggerHiddenAttribute hides the code from the debugger, even if Just My Code is turned off. DebuggerStepThroughAttribute tells the debugger to step through, rather than into, the code it is applied to.
It is possible, when Just My Code is enabled, to break the debugger at a location where there is no user code to show. In this case, no code will be shown and stepping will take you to the next line of user code. To see and to step to non-user code under this condition, disable Just My Code.
If a programmatic break is put in non-user code, such as putting a Stop statement in Windows Form Designer generated code in a Visual Basic Windows Application project, the non-user code will be shown when the Stop statement is encountered even when Just My Code is enabled, but stepping in the debugger will step to the next line of user code, skipping any intervening lines of non-user code.
Just My Code is not supported for device projects.
To enable/disable Just My Code debugging
From the Tools menu, choose Options.
In the Options dialog box, open the Debugging node and choose General.
Select/clear Enable Just My Code.