Visual Studio 2010在不安全块中杀死函数的一个参数中的数据(没有其他词)。 是什么导致了这个错误?调试器显示以下消息。

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

当前回答

I found that I had the same problem when I was running a project and debugging by attaching to an IIS process. I also was running in Debug mode with optimizations turned off. While I thought the code compiled fine, when I detached and tried to compile, one of the references was not found. This was due to another developer here that made modifications and changed the location of the reference. The reference did not show up with the alert symbol, so I thought everything was fine until I did the compilation. Once fixing the reference and running again it worked.

其他回答

关于“优化代码”属性未选中的问题,但代码仍然编译为优化:在尝试了所有东西后,最后帮助我的是在同一设置页面上检查“启用非托管代码调试”复选框(项目属性-调试)。它与代码优化没有直接关系,但是启用这个功能后,VS不再优化我的库,我可以调试。

我也有同样的问题。尝试以上所有方法,发现我还必须删除{PROJECT_ROOT}\bin\Release\netcoreapp2.2和{PROJECT_ROOT}\obj\Release\netcoreapp2.2内的所有内容。它肯定与发布有关,因为虽然我在我的Azure Web应用程序上使用部署工具/ bitbucket,但我确实尝试了Build >> Publish >> Publish to Azure,因为我想检查哪些文件实际部署了。

我只是碰到这个问题,我在发布构建配置下运行,而不是调试构建配置下运行。一旦我切换回调试我的变量显示在手表再次。

对于那些在调试Azure网站的web应用程序时遇到此问题的人,还有一个额外的答案:

例如,当从GitHub部署时,代码在默认优化的Azure服务器中编译。

通过将SCM_BUILD_ARGS设置为/p:Configuration=Debug,我告诉服务器以可调试的方式进行编译

但还有更多的选择。看到这个: http://azure.microsoft.com/blog/2014/05/08/introduction-to-remote-debugging-on-azure-web-sites-part-3-multi-instance-environment-and-git/

I found that I had the same problem when I was running a project and debugging by attaching to an IIS process. I also was running in Debug mode with optimizations turned off. While I thought the code compiled fine, when I detached and tried to compile, one of the references was not found. This was due to another developer here that made modifications and changed the location of the reference. The reference did not show up with the alert symbol, so I thought everything was fine until I did the compilation. Once fixing the reference and running again it worked.