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,因为我想检查哪些文件实际部署了。

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.

对于那些在调试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/

以我为例,我正在开发一个web api项目,尽管该项目被正确地设置为完全调试,但每当我连接到我试图调试的IIS进程时,我仍然会看到这个错误。然后我意识到发布概要文件被设置为使用发布配置。所以,如果你正在使用dotnet web api项目的“发布”功能,还有一个地方要检查你的发布配置文件。