Click here to Skip to main content
11,791,088 members (64,963 online)
Click here to Skip to main content

Tagged as

Tips on Debugging : Using DebuggerStepThrough attribute

, 22 Sep 2010 CPOL 26.1K 10
Rate this:
Please Sign up or sign in to vote.
Using DebuggerStepThrough attribute

In my few previous blog posts, I have explained how we can customize the Debugging windows view during debugging of application using “DebuggerBrowseable“ attributes and “DebuggerDisplay”, then I have also explained the use of “DubuggerHidden” attribute which tells the Visual Studio debugger that the method is hidden from the debugging process and while debugging. In this blog post, I am going to explain one similar feature of “DebuggerHidden” attribute, named “DebuggerStepThrough”.

Marking a piece of code using DebuggerStepThrough attribute tells the Visual Studio debugger that the code block will be stepped over from the debugging process. You can mark methods, properties with DebuggerStepThrough attributes where you don’t want to stop your code to break.

If there is any break point inside a code section which is marked as “DebuggerStepThrough” attributes, that code block will be marked as “[External code]” in stack Trace. Whereas “Debugger hidden” attributes which aren't marked are External code.


Let’s assume that you have the below sample code snippet where Method1() marked as with debuggerStepThrough() attributes.


Now if you run your application, the debugger will stop at line number 37 inside Method2() [Note: Line number I am using only for reference of that above code], though you have a break point at Line number 20, inside method1(). But, as Method1() has marked as “DebuggerStepThrough”, the breakpoint didn’t hit over there.

While the breakpoint stopped at the method2(), just open the call stack window as shown below:


As per the about Call stack window, Live breakpoint position is Line number 37 which is inside the Method2(), and method2() has been called from method1(). Though the method1() has a break point, it doesn’t hit due to “DebuggerStepThrough” attributes.

The breakpoint position of method1() has been marked as “[ExternalCode]”. To make it sure, just right click on “Call Stack” window and select “Show External Code” option.


This change will show you the exact line from where it has been called which is marked as “External Code”. The below screen shows the exact line of call for the external code which was marked as “DebuggerStepThrough”.


Once you select the “Show External code” option, you can see the exact line number from where the method2() was called. You can also verify the same by just clicking one of the lines at the call stack window.

You can apply the “DebuggerStepThrough” attributes with properties also. But for that, you have to apply the attributes to get and set statement not with the properties name.



In this blog post, I have explained how we can use “DebuggerStepThrough” attributes to a piece of code so that the code is stepped over while debugging. If there is any breakpoint inside that code block, that will be marked as “External Code”. This thing save a lot of time of development if you don’t want to step into some code always or unless they raise some exception. This is also very much a time saver when you applied it for properties too.

Hope this will help you!


Filed under: General, Tips and Tricks, Visual Studio, Visual Studio 2010


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


About the Author

Abhijit Jana
Technical Lead
India India
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband

Blog :
Web Site :
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Krekkon18-Oct-13 9:22
memberKrekkon18-Oct-13 9:22 
GeneralMy vote of 5 Pin
Brij24-Sep-10 6:04
mentorBrij24-Sep-10 6:04 
GeneralRe: My vote of 5 Pin
Abhijit Jana24-Sep-10 6:42
mvpAbhijit Jana24-Sep-10 6:42 
GeneralMy vote of 5 Pin
KunalChowdhury23-Sep-10 19:56
mentorKunalChowdhury23-Sep-10 19:56 
GeneralRe: My vote of 5 Pin
Abhijit Jana24-Sep-10 6:42
mvpAbhijit Jana24-Sep-10 6:42 
GeneralMy vote of 5 Pin
Abhishek Sur22-Sep-10 9:39
mvpAbhishek Sur22-Sep-10 9:39 
GeneralRe: My vote of 5 Pin
Abhijit Jana22-Sep-10 10:41
mvpAbhijit Jana22-Sep-10 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1509028.1 | Last Updated 22 Sep 2010
Article Copyright 2010 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid