“Cannot evaluate expression because the code of the current method is optimized” in Visual Studio 2010

后端 未结 22 696
耶瑟儿~
耶瑟儿~ 2020-12-23 08:59

I am using Visual Studio 2010 in debug mode and I have \"optimize code\" unchecked. I can\'t quick watch (or hover on) any variable in the debugger. I get this error \"Canno

22条回答
  •  无人及你
    2020-12-23 09:04

    It sounds like you are debugging an optimised / release build, despite having the optimised box un-checked. Things you can try are:

    • Do a complete rebuild of your solution file (right click on the solution and select Rebuild all)
    • While debugging open up the modules window (Debug -> Windows -> Modules) and find your assembly in the list of loaded modules. Check that the Path listed against your loaded assembly is what you expect it to be, and that the modified timestamp of the file indicates that the assembly was actually rebuilt.
    • The modules window should also tell you whether or not the loaded module is optimised or not - make sure that the modules window indicates that it is not optimised.

    If you cant't see the Modules menu item in the Debug -> Windows menu then you may need to add it in the "Customise..." menu.

提交回复
热议问题