views:

1220

answers:

5

Hi folks,

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?

+1  A: 

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.

Robert Wagner
Correct Robert. I'm inside the code that is downloaded from the Microsoft Symbol Server for .NET. For example, the above happens inside SetAuthCookie(..) method, inside System.Web.Security.FormsAuthentication class ... which of course got downloaded from ms's symbol server.
Pure.Krome
This is not 100% correct. Most of the errors you are seeing are a result of runtime JIT optimizations. These are suppressable by a .INI file (see my post). There is some opmitazation in the BCL but most of it won't affect debugging if JIT optimazations are suppressed.
JaredPar
From the reading you need to put the ini file next to the DLL/EXE that you want to affect. Where do you put it for the BCL libraries?
Robert Wagner
+2  A: 

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.

JaredPar
Hi JaredPar. I know i'm casting 'resurect dead' upon this thread, but can u give some more info if i'm debugging locally against cassini?
Pure.Krome
@Pure.Krome, have you tried adding <compilation debug="true" /> to web.config? See http://support.microsoft.com/kb/815157
JaredPar
A: 

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.

+7  A: 

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.

Cameron MacFarland
A: 

Thank you so much SBSBSB. Almost a year later from when you posted and your answer helped me!