DCSIMG
Step Into .NET Framework 4.0 Source Code - Arik Poznanski's Blog

Arik Poznanski's Blog

It CAN be done with .NET

News

MVP

MCC

CodeProject MVP

MCPD

MCTS

Subscribe to my blog by email

Arik Poznanski LinkedIn Profile

Email: arik.com at gmail dot com
or, use this form

Locations of visitors to this page


Sela Group

Sela Canada

DZone MVB

Links

Official Blogs

WPF / SL Blogs

Developers Blogs

Step Into .NET Framework 4.0 Source Code

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 its cool.

Because it helps with debugging.
Not only you can see the code but you can 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 at 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

4. 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 followings:

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

image

  • Make sure you didn’t install it in to \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 search 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  

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# July 12, 2010 3:27 PM

Step Into .NET Framework 4.0 Source Code – Arik Poznanski's Blog « Amazing Source said:

Pingback from  Step Into .NET Framework 4.0 Source Code – Arik Poznanski's Blog «  Amazing Source

# July 13, 2010 6:13 AM

Step Into .NET Framework 4.0 Source Code – Arik Poznanski's Blog | Programming Blog Imagik.org said:

Pingback from  Step Into .NET Framework 4.0 Source Code – Arik Poznanski's Blog | Programming Blog Imagik.org

# July 13, 2010 6:33 AM

Arik Poznanski's Blog said:

Back in this post I showed you how you can have a look at the original source code of .NET, including

# August 12, 2010 9:09 PM

Mal Ross said:

For anyone else who has problems with seeing variable values once stepping through the framework source, this StackOverflow question sorted me out:

stackoverflow.com/.../cant-see-params-while-stepping-through-net-4-0-source-in-c-vs2010

# April 6, 2011 12:01 PM

The.net source debugging said:

Pingback from  The.net source debugging

# July 2, 2011 5:48 PM

Fernando Gonzalez Sanchez said:

Cool. Does this include all assemblies from .NET 4.0?

# July 4, 2011 9:46 PM

.net 4 Source Code said:

Pingback from  .net 4 Source Code

# July 7, 2011 1:21 AM

ofy said:

It seems that source code for System.Windows.Forms.dll isn't included in the setup. I'm able to browse System.Drawing.dll source code but cannot browse System.Windows.Forms.dll source code.

# August 23, 2011 3:55 PM

Visual Studio 2010 | trouble86.com said:

Pingback from  Visual Studio 2010 | trouble86.com

# November 2, 2011 12:41 PM

Arik Poznanski's Blog said:

I feel this is a good time for me to present a summary of some of the posts I wrote.. Most Interesting

# November 20, 2011 12:13 AM

Arik Poznanski's Blog said:

I feel this is a good time for me to present a summary of some of the posts I wrote.. Most Interesting

# November 20, 2011 12:14 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: