views:

374

answers:

5

Is there any way for people using VS2008 to step into and read the source code for the MSDN libraries?

I come from a Java background where this is possible...

+3  A: 

The best way I can give you is using .NET reflector from RedGate (its free). You can't step into it, but it will give you the complete source code for various .NET classes.

LorenVS
actually you can debug with visual studio and reflector. Including stepping into, breakpoints etc... see http://orand.blogspot.com/2006/10/debugging-with-reflector-and-visual.html but the answer Martin gave is easier in the specific case of the .net framework.
olle
+20  A: 

Yes it's possible. Have a look at the following blog post by Shawn Burke for details:

Configuring Visual Studio to Debug .NET Framework Source Code

On the other hand, if you simply want to check out how certain things are implemented in the .NET framework (without debugging), then use .NET Reflector (as mentioned by LorenVS). This is a very useful tool that can help you a lot to understand the .NET framework.

M4N
You beat me to the same blog link by 30 seconds ;)
Thomas Dufour
A: 

It is possible to use reflection and ILDASM to look at the IL, but I dont think it is possible to step into the code while debugging.

DevByDefault
+1  A: 

Hi there.

I recently did some debugging in VS which included getting some .NET source code (OleDB related) which I could step into and see what was going one. One thing I would mention, when your stepping through .NET source code, don't expect the locals window (or data tips) to always show you the value of variables.

For example, simple variables like int, longs, string, etc, you will be able to get the value of. But try to get the value of objects (List<>, custom objects, DataTable, etc) and you will get nothing but a message saying the code has been optimized and you cannot see the values.

Even though you have the .NET source, the actual compiled code that your attached to is the release build with optimizations enabled. This means that much of the data for variables and objects is unavailable to analyse.

Just a heads-up.

Cheers. Jas.

Jason Evans
+3  A: 

My 3 cents:

  1. If you have Visual Studio 2008 SP1 or later, you don't have to install the QFE mentioned in the Configuring Visual Studio to Debug .NET Framework Source Code blog post
  2. As much a fan as I am of .NET Reflector, the source code is better because local variable names and comments are preserved. Comments and proper variable names can help a lot!
  3. You can download (almost) all the .NET Framework source code at once using NetMassDownloader. This becomes very usefull when you're at a place without internet access.
Alfred Myers
AB Kolan