Click here to Skip to main content
15,888,454 members
Articles / .NET / .NET4

Step Into .NET Framework 4.0 Source Code

Rate me:
Please Sign up or sign in to vote.
4.86/5 (6 votes)
12 Jul 2010Ms-PL2 min read 49.4K   14   8
How to configure your Visual Studio 2010 to step into the source code of .NET Framework 4.0.

Introduction

In this post, I'll show you how to configure your Visual Studio 2010 to step into the source code of .NET Framework 4.0.

Why?

Because it's cool.

Because it helps with debugging.
Not only can you see the code, but you can also step into it.

Because unlike with Reflector, you get the code with the original comments and variable names!

Step 1: Download Source

Go to http://referencesource.microsoft.com/netframework.aspx.

Download from the line marked with Product Name: .NET, Version: 4.
That's a 175MB download.

image

Step 2: Install Source

Install “Net_4.msi”, which you have downloaded in the previous step.

I've installed it into: “D:\RefSrc\”.
The installed size is approximately 1GB of source and symbols (are you excited yet?)

image

Step 3: Setup Visual Studio 2010

For configuring Visual Studio 2010:

  1. Launch Visual Studio 2010.
  2. From the Tools menu, choose Options.
  3. In the Options dialog box, open the Debugging node and select General
    • Uncheck "Enable Just My Code (Managed only)"
    • Check "Enable source server support"
    • Uncheck "Require source files to exactly match the original version"
    • Optional: Uncheck “Step over properties and operators (Managed only)”

image

  1. Select Symbols under Debugging.

    In the Symbol File Locations box, add the downloaded symbols location:
    D:\RefSrc\Symbols”.
    Note: To add the Symbols path, click on the folder icon.

    Enter in text box under 'Cache symbols in this directory’:
    D:\RefSrc\Symbols\Cache”.

image

That’s it, you can now try to F11 (Step Into) .NET source code.

Troubleshooting

If you fail to see the symbols, try one of the following:

  • Make sure you debug a program under .NET Framework 4.0.

image

  • Make sure you didn't install it into \Program Files\, since you need elevated permissions to write to there. If you already installed it there, you can either run Visual Studio 2010 as Administrator or just change the cache folder to some other writable folder.
  • While running, Right Click on the Call Stack, on some grayed .NET functions, select “Load Symbols From” and then “Symbol Path”.

image

  • If you encounter the “No Source Available” screen, try to press “Browse to Find Source” and find the file you need in the source directory. You should probably need to use files search to find it.
    This is done only once, since from now on Visual Studio remembers this location and searches there for missing source files.

image

Finally, you can find more information at http://referencesource.microsoft.com/.

That’s it for now,
Arik Poznanski.

kick it on DotNetKicks.com Shout it
This article was originally posted at http://feeds.feedburner.com/ArikPoznanskisBlog

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) Verint
Israel Israel
Arik Poznanski is a senior software developer at Verint. He completed two B.Sc. degrees in Mathematics & Computer Science, summa cum laude, from the Technion in Israel.

Arik has extensive knowledge and experience in many Microsoft technologies, including .NET with C#, WPF, Silverlight, WinForms, Interop, COM/ATL programming, C++ Win32 programming and reverse engineering (assembly, IL).

Comments and Discussions

 
QuestionWhere is 4.0 source? Pin
Member 568844326-Apr-21 9:25
Member 568844326-Apr-21 9:25 
Questionsource code not available Pin
deetwa4-Feb-17 4:32
deetwa4-Feb-17 4:32 
QuestionBrowse To Find Source is disabled Pin
Alexander Batishchev12-Nov-11 8:18
Alexander Batishchev12-Nov-11 8:18 
QuestionWhat about System.web ?? Pin
Xavier8317-Jan-11 4:52
Xavier8317-Jan-11 4:52 
GeneralAvaliable namespaces Pin
DarkWalkerRzn20-Jul-10 3:00
DarkWalkerRzn20-Jul-10 3:00 
GeneralRe: Avaliable namespaces Pin
Arik Poznanski21-Jul-10 21:57
Arik Poznanski21-Jul-10 21:57 
General.Net Version 8.0 Pin
[CC]19-Jul-10 23:17
[CC]19-Jul-10 23:17 
GeneralRe: .Net Version 8.0 Pin
Arik Poznanski21-Jul-10 21:58
Arik Poznanski21-Jul-10 21:58 

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

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