ASP.NET MVC source debugging the easy way

by Martin Meixger – 2 years ago

If you want to step into the ASP.NET MVC source code you should use MS Public Symbol server for the .PDB files and the ASP.NET MVC source code ( witch should be be extracted in “c:\dd\Mvc\…” because Visual Studio will look there for it ).

But when inspecting variables you will encounter the errors:

“Cannot evaluate expression because the code of the current method is optimized.”

”Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.”

Now you could compile the MVC source yourself without strongly typed name and replace the assembly in your solution or even in the GAC, with all the shortcomings.

But there is an easier method:

Just disable the JIT-compiler’s optimizations by creating a simple .INI file.

Go to the directory where System.Web.Mvc.dll is located:

c:\Windows\assembly\GAC_MSIL\System.Web.Mvc\2.0.0.0__31bf3856ad364e35\

Create the file System.Web.Mvc.ini

[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0

Next time you step into the MVC source code you can inspect all variables.

4 Comments

  1. 3340 Vijay says:
    11/2/2013 5:58:21 PM
    I have explained some detailed step-by-step instructions to download asp.net mvc 4 source code and setup debugging in my blog. Hope it is useful. (http://vijayt.com/Post/Setting-up-aspnet-mvc-for-debugging-in-your-system)
  2. 3342 Umesh says:
    3/26/2014 12:16:12 PM
    Hi, I am using the System.Web.Mvc.dll from the bin folder and created the ini file in the same folder also created in the Gac as well, but still can't inspect all variables. I am using MVC dll version v4.0.30319.
  3. 6/26/2014 1:42:11 AM
    ϜormidaƄle post, pérennise dans cette voie
  4. 7/7/2014 1:37:55 PM
    Très bon article, j'en parlerai plus tard avec des amis

Leave a Comment

Martin MeixgerAbout Me

  • Software architect
  • South Tyrolean
  • Outdoor enthusiast
Blogroll