Menu: Tools -> Options -> Debugging -> General
Ever notice the “Enable Just My Code” option in Tools -> Options -> Debugging -> General?
Lots of people wonder what “Just My Code” really means. I thought it would be a good idea to explore this in a little more detail. So let’s start with what the documentation says (http://msdn.microsoft.com/en-us/library/h5e30exc.aspx):
“To distinguish user code from non-user code, Just My Code looks at three things: DBG Files, PDB files, and optimization.”
DBG and PDB files
One way to figure out what is “your code” is to look and see if it has DBG and/or PDB files. In case you didn’t know, DBG files have been superseded by the PDB format. The PDB extension stands for “program database.” It holds the debugging information that was introduced in Visual C++ version 1.0. You can find out more about PDB files here: http://support.microsoft.com/kb/121366/en-us. This is typically deep level information about the source so if you have these files either it’s your code or someone trusted you enough to give them to you.
When optimization is turned off (the default setting for Debug builds) then that factors into the code being considered “yours”. According to the documentation, the optimization “option enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient”. There are a ton of optimizations that you can do such as optimizing for application speed or size of your program. You can get a sense of the full list of features here: http://msdn.microsoft.com/en-us/library/k1ack8f1.aspx. Basically, it does a lot of cool things that are great for a shipping application but not for one that you are currently working on.
In C# this is found in the Project properties on the Build tab:
In VB, it is also in the Project properties on the Compile tab but you have to click the “Advanced Compile Options” button:
So if the PDB information is there and optimization is NOT turned on then the code is considered “yours” as far as Visual Studio is concerned. And now you know what “Just My Code” means when you are debugging.