Question

When I debug my ASP.NET web site code using the Microsoft debug symbol's for .NET .. I keep getting this silly 'result' for most of the variables when I'm debugging .NET framework code (which of course is provided by the Microsoft Symbol Server, which I told VS2008 to grab the info, from)

Cannot obtain value of local or argument 'cookie' as 
it is not available at this instruction pointer, possibly because 
it has been optimized away.

It's like the code I'm using is using optimized, compiled code. If that's the case, can I tell it NOT to optimize? I'm in DEBUG configuration. It's very frustrating because I cannot debug .. cause I can't see/retrieve the values of local variables as I step through the code.

Any clues/thoughts?

Was it helpful?

Solution

Shawn Burke described a method of disabling this on his blog.

First, create a CMD that'll load Visual Studio without JIT optimization.

set COMPLUS_ZapDisable=1
cd /d "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\ide\"
start devenv.exe
exit

Once in your Visual Studio project, do the following steps:

1) Right click on your project file and choose "Properties"

2) Choose the "Debug" tab and uncheck "Enable the Visual Studio Hosting Process"

3) Launch your application in the debugger.

OTHER TIPS

For a normal .Net application you can disable the use of JIT optimizations with an .INI file next to the starting binary. Here's a link to how this is accomplished

http://blogs.msdn.com/jaredpar/archive/2008/08/29/disabling-jit-optimizations-while-debugging.aspx

Debugging ASP.Net is a bit different though and I'm not sure if this will work for you. If you are debugging locally using the light weight web server (cassini) you can apply this trick to Cassini itself. If you are debuggin directly on a web server though inside of IIS I don't know how to get this trick to work but hopefully it will lead you in the right direction.

After a lot of research, I was able to find a way to also make this "COMPLUS_ZapDisable" technique work when attaching to an IIS-hosted application under IIS7/Windows 7 x64.

In my case, I'm using symbols constructed by Reflector Pro, although my guess is that it will also work for the Microsoft symbols that the OP asked about.

The trick is in finding the right place to set that environment variable so that your w3wp.exe is launched with that setting enabled. To do this, add a string key called "COMPLUS_ZAPDISABLE" to your registry at "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment". Set the key value to "1", and that should do the trick. Don't do this on production =)

Kudos to Clive Tong, the author of this post from Red Gate, for pointing me in the right direction.

The .NET framework code is optimized, so you will not be able to view all the variables as they probably don't exist in the optimized code. I assume you are trying to debug inside the .NET framework itself. Nothing much you can do about it unfortunatly.

Finally, this solution worked for me when attaching to the aspnet_wp.exe Visual Studio 2008, .NET framework 2.0 : go into the project properties, into Build tab, Advanced button -> set Output Debug Info to "full". Hope this helps someone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top