Saturday, January 26, 2013

Fix No source available problem when debug ASP.Net internal code

Sometimes you need to debug internals of ASP.Net. It helps to understand some important aspects of functioning of the framework and improves the understanding of how it works in general. Here is the good article which explains how to configure Visual Studio for debugging .Net code (which of course includes ASP.Net code): Configuring Visual Studio to Debug .NET Framework Source Code. This article was written for VS2008, in VS2010 and VS2012 steps are almost the same, bug there are several improvements. First of all there is new “Enable .NET Framework source stepping” setting:

image

This msdn article How to: Debug .NET Framework Source says that we need to check it in order to be able to step into the .Net code. However on practice I was able to debug .Net code even with having it unchecked.

Another improvement is having preconfigured Microsoft Symbols Servers option in Tools > Debugging > Symbols:

image

So now you don’t need to add and configure it manually.

Ok, so you did all described steps, tried to debug your ASP.Net application, set breakpoint e.g. in Page_Load method of your page and in Call Stack window can see that symbols for whole stack are loaded properly:

image

Also if you will check Symbol Load Information from the context menu:

image

you will see that symbols are successfully loaded:

image

However if you will try to double click on any row in Call Stack window you may see the message that source code is unavailable:

image

It may be confusing because you did everything according to instructions which you found in many blog posts and forums. However there is one more important thing which you should do. In order to debug ASP.Net code use real IIS web server in the project settings instead of Visual Studio Development Server:

image

After you will change project settings and click on some .Net internal call from Call Stack you will see the .Net source code:

image

Hope that this information will help you during the debugging.

No comments:

Post a Comment