Debug .NET Source Code

Scott Guthrie announced some weeks ago that Microsoft will offer the source code of the .NET framework. The source code will be released under the Microsoft Reference License (MS-RL) and includes all comments which is very useful.

The last days I had a more deeper look inside. First I tried to create a small ConsoleApplication1 and debug the Console class:

image 

Well, pressing F5 will stop at the breakpoint, but F11 doesn't open the Console.cs which contains the source code of the Console class. To get the .NET source code for System.Console you need to load the symbols for the mscorlib.dll by right-clicking on the Call Stack and select Load Symbols.

The Call Stack will then change from gray line for mscorlib.dll to black:

call stack before loading symbols

call stack after loading symbols 

After loading the symbols for mscorlib.dll you are able to press F11 do step into the Console class. First Visual Studio will display some license dialogs that you have to accept... and the you will see the Console.cs and are able to debug each line.

image 

Upps, I modified the Console.cs (I see the yellow indicator on the left side), but you are not able to compile a new .NET version, of course.

While extending the very simple debug test I tried to debug the XmlDocument class. I added some lines to load an XML fragment:

image

I started the debugger by pressing F5 and stopped at the breakpoint. Having a look at the call stack I couldn't find the System.Xml.dll, of course. But how can I debug the XmlDocument class now?

What you have to do is loading the symbols for System.Xml.dll. This can be done by opening the Modules window (Debug -> Windows -> Modules or by pressing Ctrl+D, M). In the Modules window you will find the System.Xml.dll, right-click on it and select Load Symbols.

image 

Now you are able to debug the XmlDocument by pressing F11 while in debug mode:

image

Published Wednesday, December 19, 2007 2:44 PM by Michael Schwarz

Comments

# re: Debug .NET Source Code

Wednesday, December 19, 2007 10:02 AM by alerch

Why do you torture us? What's the URL for the symbol/source server? :)

# re: Debug .NET Source Code

Wednesday, December 19, 2007 10:08 AM by Michael Schwarz

Well, because it is not available for public yet. I think end of this year Microsoft will publish the URL for the symbol and source server. I will then write a short post here at my blog with further details, sorry.

Michael

# re: Debug .NET Source Code

Wednesday, December 19, 2007 11:02 AM by Bart P

Michael

I cannot wait for this cool future.

Bart

# re: Debug .NET Source Code

Wednesday, December 19, 2007 11:17 AM by Alex Dresko

This information doesn't do us much good if we mere mortals can't download the symbols.

# re: Debug .NET Source Code

Wednesday, December 19, 2007 11:58 AM by Mel Grubb

Stop rubbing it in, already!

# re: Debug .NET Source Code

Wednesday, December 19, 2007 10:55 PM by Chinh Do

End of the year? Ok... I can wait 11 more days :-)

# re: Debug .NET Source Code

Sunday, January 6, 2008 3:15 AM by Jake

Well, the end of the year has come and gone... Any update? Hmm? Please..