How to debug c# source code of .net framework in visual studio 2017 ?

Yash Maheshwari 0 Reputation points
2023-07-10T11:08:01.09+00:00

I am using Visual studio to debug framework level code, I followed https://referencesource.microsoft.com/setup.htmlarticle and also downloaded the source code from https://referencesource.microsoft.com/download_47.html, While debugging when hitting the HttpWebRequest.cs debugger is not pointing to correct code, It it hitting some empty-space or comments arbitrarily.
Screenshot 2023-07-10 at 4.30.46 PM

I guess source code is not correctly mapped.
I tried deleting bin folder, clean and re-build project, restarting the pc, Empty symbol cache.
Please suggest how can I troubleshoot this issue.

Thanks in advance.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,040 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,015 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 86,486 Reputation points
    2023-07-10T13:07:53.15+00:00

    Are you sure that you use the same version as the source ?

    For example, with VS 2022, I use 4.8 :

    User's image

    and the source is :

    E:\Sources\DotNet48ZDP2\Source\ndp\fx\src\net\System\Net\HttpWebRequest.cs

    and debugging works fine :

    GetResponse

    0 comments No comments

  2. Anna Xiu-MSFT 30,561 Reputation points Microsoft Vendor
    2023-07-10T13:08:19.0066667+00:00

    Hi @Yash Maheshwari, 

    Welcome to Microsoft Q&A! 

    Please refer to: Debug .NET Framework source and go to Tools > Options > Debugging > Symbols > check “Microsoft Symbol Servers”. 

    You can view the similar issue

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.rs to provide solutions to the user's question.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.