• Register
0 votes

Problem :

I am using the Visual Studio 2010 in a debug mode and I have "optimize code" unchecked. I am unable to quick watch (or hover on) any variable in my debugger. I encountered following error "Cannot evaluate expression because the code of the current method is optimized".

Even the line like: int i = -3, doing the quick watch on i, I encountered following error "Cannot obtain value of local or argument 'i' as it is not available at this instruction pointer, possibly because it has been optimized away."

Am I missing any setting here ?

3.9k points
edited by

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

While my project was in the debug mode, my solution was not. So when I changed it, everything worked for me.


I had this same issue when I was using the VS 2010. My solution configuration has a (Debug) selected. I resolved this by simply unchecking a Optimize Code property under a project properties. Follow it  Project (right Click)=> Properties => Build (tab) => uncheck Optimize code


In the VS2013 go to: Tools -> Options -> Debugging -> General and enable the 'Use managed compatibility mode'. This disables your new function evaluation behavior.

Hope above solutions help you in resolving your issue.

38.6k points

Related questions

1 vote
1 answer 153 views
Problem: Why I got the error : The name 'InitializeComponent' does not exist in the current context. I create a new project in Visual Studio 2010 SP1 and select "WPF Application" .When I tries to build the generated its show Error.
asked Mar 20 Sabbir Hossain 14.6k points
1 vote
1 answer 29 views
Problem : When I run the program there's an error in cmd.ExecuteReader(). Data type mismatch in criteria expression ,I got this : Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Dim con As New OleDbConnection("Provider=Microsoft. ... valid!") Me.Hide() Else MessageBox.Show("Invalid Tenant ID or password!") End If Please help how to fix this error?
asked Apr 14 Sabbir Hossain 14.6k points
0 votes
1 answer 62 views
Problem: Get a error liek this: input array is longer than the number of columns in this table.both datatable have 6 columns, what could be the problem?
asked May 4 sumaiya simi 43.9k points
0 votes
1 answer 23 views
Problem : What is the most effective strategy for me to resolve this issue: The application which this project type is based on was not found?
asked Jun 19 Sifat55 108k points
0 votes
1 answer 7 views
Problem: C# web application tutorial visual studio 2015
asked Jul 9 Hridoy 19.2k points
0 votes
1 answer 6 views
Problem: Visual studio 2010 free download for windows 10
asked Jul 5 asha 121k points
0 votes
1 answer 31 views
Problem: Download visual studio 2010 sp1 offline installer
asked Jun 30 asha 121k points
0 votes
1 answer 14 views
Problem: What am I going to do about it: Microsoft visual studio 2010 free download for windows 10 64 bit?
asked Jun 20 Shifa 18.2k points
0 votes
1 answer 4 views
Problem: 1>link : fatal error lnk1104: cannot open file?
asked Jul 6 Mezbah 130k points
0 votes
1 answer 17 views
Problem: Httputility does not exist in the current context?
asked Jun 29 Mezbah 130k points