Cannot find .cs files for debugging .NET source code

后端 未结 11 2180
清酒与你
清酒与你 2020-11-29 23:04

I tried setting up debugging the .NET source by following this MDSN walkthrough. The Symbol cache is setup properly, as is the check \'Enable .NET Framework source stepping\

相关标签:
11条回答
  • 2020-11-29 23:25

    The answers here all talk about ignoring/avoiding the source code instead of actually stepping into it.

    @JBSnorro is on the right track but the issue is Microsoft doesn't appear to publish all the .NET symbols/source you might encounter. I don't know if it is intentional on their part but to step into MS sources they need to publish every version of every assembly which is a big logistical task.

    Tools -> Options -> Debugging -> General -> Enable source server support will work in many cases but I found for example mscorlib.dll for 4.6.1 was lacking symbols and/or decompiled source. So I couldn't step into common source code like Dictionary.cs or Task.cs as examples. Since MS symbol server's source & symbols likely change all the time. My issue may be resolved by the time you read this?

    When I debug the same solution in Jetbrain's Rider, I can see and step through every class in every .NET assembly with no issue. However in VS I can only step into some class but not into others?

    If you are really committed to stepping into all .NET source code you can use Jetbrain's DotPeek and decompile the .NET assemblies to actual .cs files to your disk. Then when you see this,

    You can now browse your disk to the source code you decompiled using DotPeek. Just make sure you decompiled the same assembly version you reference in your project. If not, the symbols may not match up with the correct source line numbers.

    Instead, If you just want to hide this "Source Not Found" from constantly appearing and you don't care to step into the code there are no sources for, read @Alex Sherman's answer. You will need to figure out what assembly the offending file is contained in, then add that assembly name to the exclusion list.

    Food for thought, I'm not a fan of Rider over VS. Rider is still a touch raw and lacks the crazy amount of built in tooling VS has. However!! I like to have it installed side-by-side in cases like this where I know I can get deeper into the weeds.

    0 讨论(0)
  • 2020-11-29 23:27

    Had the same issue, neither proposed above solutions helped me to solve the problem. Occurred in VS 2017. When I ran the project in Visual Studio 2019, everything worked. So just try to run it in other environments. Hope this answer will help someone

    0 讨论(0)
  • 2020-11-29 23:28

    I've tried all the answers from above and nothing worked.

    This solved it for me:

    Debug -> Delete all Breakpoints

    and it solved the problem! So many different things causing this issue.

    0 讨论(0)
  • 2020-11-29 23:32

    This took me an hour as well. I fixed it finally by resetting the Settings -> Tools -> Import and Export Settings -> Reset all settings

    0 讨论(0)
  • 2020-11-29 23:35

    If the error is from looking for "nullable.cs" or some other core source file:

    You can disable symbols for specific modules by using Debug -> Options -> Debugging -> Symbols and then on the bottom Specify Excluded Modules.

    This is useful for cases where you do want to disable "Just My Code" to step into other assemblies that you have PDBs for. Visual Studio I think comes with symbols for mscorlib.dll but does not include the source so sometimes stepping into things will look for a "nullable.cs" or some other core source file.

    0 讨论(0)
提交回复
热议问题