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.

当前回答

在visual Studio 2017中 去调试->选项,然后检查调试->通用-> 选中这个选项

其他回答

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

检查您的AssemblyInfo文件中是否有Debuggable属性。如果存在,则删除它并重新构建解决方案,以查看本地变量是否可用。

我的可调试属性被设置为:DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints,根据这篇MSDN文章,它告诉JIT编译器使用优化。我从我的AssemblyInfo.cs文件中删除了这一行,本地变量就可用了。

转到“项目属性”,在“构建”下确保“优化代码”复选框未选中。

此外,在高级选项(在构建选项卡下)中将“调试信息”下拉菜单设置为“完全”。

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.

在visual Studio 2017中 去调试->选项,然后检查调试->通用-> 选中这个选项