What is 'Just My Code'?

Visual Studio

Visual Studio Problem Overview


Visual Studio has an option (under Debugging / General) "Enable Just My Code"

What is 'Just My Code'? Visual Studio doesn't explain the feature.

enter image description here

Visual Studio Solutions


Solution 1 - Visual Studio

From Visual Studio Docs:

> Enable Just My Code: The debugger displays and steps into user code ("My Code") only, ignoring system code and other code that is optimized or that does not have debugging symbols.

Solution 2 - Visual Studio

As long as the feature is pretty self-explanatory - debugger skips external code - I think it is also worth mentioning what actually counts as 'My Code' according to Microsoft. In context of the .NET projects that is:

Not My Code:

  • any optimized library (e.g. Release Mode)
  • libraries without .pdb (no debugging symbols)
  • Classes or members marked with [DebuggerNonUserCode] or [DebuggerHidden]. Also [DebuggerStepThrough] affects it

My Code:

  • Any project with loaded .pdb (with debugging symbols) for which none of the above applies

An easy way to see how project dependencies will be treated by the debugger and if they have debugging symbols loaded is to check the Modules window (Debug -> Windows -> Modules, visible only during debugging), which offers a User Code column.

On a practical side, any not-user-code is marked as [External Code], while debugging.

Solution 3 - Visual Studio

You need PDB files to debug other code such as any library that might be statically or dynamically linked to your code. With the above option, you're only debugging (your) active part of the code.

Solution 4 - Visual Studio

A quick way to fix it or we can say run your code in default debugging state is:

Find out the Solution Configuration option in the Visual Studio Tools tray, changes the selected option to "Debug".

Change Solution Configuration To Debug

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionColonel PanicView Question on Stackoverflow
Solution 1 - Visual StudioColonel PanicView Answer on Stackoverflow
Solution 2 - Visual StudiomikusView Answer on Stackoverflow
Solution 3 - Visual StudioLemonColdView Answer on Stackoverflow
Solution 4 - Visual StudioParamjot SinghView Answer on Stackoverflow