Jack Kada
Jack Kada

Reputation: 25202

Is it possible to Read and Step into .NET Framework Source Code

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

Upvotes: 8

Views: 615

Answers (5)

LorenVS
LorenVS

Reputation: 12857

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

Upvotes: 4

Jason Evans
Jason Evans

Reputation: 29186

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.

Upvotes: 2

Alfred Myers
Alfred Myers

Reputation: 6453

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.

Upvotes: 3

M4N
M4N

Reputation: 96561

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.

Upvotes: 21

DevByDefault
DevByDefault

Reputation: 664

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.

Upvotes: 1

Related Questions