使用 MS 的符号服务器调试 .NET 代码 - VS 不显示变量值
当我使用 .NET 的 Microsoft 调试符号调试 ASP.NET 网站代码时。当我调试 .NET 框架代码(当然是由Microsoft Symbol Server,我告诉 VS2008 从它获取信息)
Cannot obtain value of local or argument 'cookie' as
it is not available at this instruction pointer, possibly because
it has been optimized away.
这就像我正在使用的代码正在使用优化的编译代码。 如果是这样的话,我可以告诉它不要优化吗? 我处于调试配置。 这非常令人沮丧,因为我无法调试..因为我在单步执行代码时无法查看/检索局部变量的值。
有任何线索/想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
.NET 框架代码已经过优化,因此您将无法查看所有变量,因为它们可能不存在于优化的代码中。 我假设您正在尝试在 .NET 框架本身内部进行调试。 不幸的是,你对此无能为力。
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.
最后,当附加到 aspnet_wp.exe Visual Studio 2008、.NET Framework 2.0 时,此解决方案对我有用:进入项目属性,进入“构建”选项卡,“高级”按钮 ->“ 将输出调试信息设置为“完整”。 希望这对某人有帮助。
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.
Shawn Burke 在他的 博客。
首先,创建一个 CMD,它将在不进行 JIT 优化的情况下加载 Visual Studio。
进入 Visual Studio 项目后,请执行以下步骤:
1) 右键单击项目文件并选择“属性”
2) 选择“调试”选项卡并取消选中“启用 Visual Studio 托管进程”
3) 在调试器。
Shawn Burke described a method of disabling this on his blog.
First, create a CMD that'll load Visual Studio without JIT optimization.
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.
对于普通的 .Net 应用程序,您可以通过启动二进制文件旁边的 .INI 文件来禁用 JIT 优化。 这是如何完成此操作的链接
http://blogs.msdn.com/jaredpar/archive/2008/08/29/disabling-jit-optimizations-while-debugging.aspx
调试 ASP.Net 有点不同,但我不是确定这是否适合你。 如果您使用轻量级 Web 服务器 (cassini) 进行本地调试,则可以将此技巧应用于 Cassini 本身。 如果您直接在 IIS 内部的 Web 服务器上进行调试,我不知道如何让这个技巧发挥作用,但希望它能引导您走向正确的方向。
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.
经过大量研究,我找到了一种方法,使这种“COMPLUS_ZapDisable”技术在附加到 IIS7/Windows 7 x64 下的 IIS 托管应用程序时也能发挥作用。
就我而言,我使用的是 Reflector Pro 构建的符号,尽管我猜测它也适用于 OP 询问的 Microsoft 符号。
诀窍在于找到正确的位置来设置该环境变量,以便您的 w3wp.exe 在启用该设置的情况下启动。 为此,请将名为“COMPLUS_ZAPDISABLE”的字符串键添加到注册表“HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment”中。 将键值设置为“1”,这样就可以了。 不要在生产中这样做 =)
向 Clive Tong 致敬,他是 这篇来自 Red Gate 的帖子,为我指明了正确的方向。
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.