Debug .NET Source Code

Posted by: Ajax.NET Professional, on 19 Dec 2007 | View original | Bookmarked: 0 time(s)

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

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: .NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1838 | Hits: 66

Similar Posts

  • Neat VS10 Feature: Pinning A Debugger Watch more
  • MPI Project Template for VS2010 more
  • Data-binding Telerik CoverFlow for Silverlight + some Routed Commands goodness more
  • Debug Out Of Browser (OOB) Silverlight apps more
  • VS2010 Beta 2 : Pin to Source for debugging COOL! But with a caveat more
  • VS 2010 and .NET 4.0 Beta 2 more
  • Announcing Visual Studio 2010 and .NET FX 4 Beta 2 more
  • Experimenting with MongoDB from C# more
  • .Net Debugging? Dont give me none of your VS more
  • My History of Visual Studio (Part 2) more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD