Click here to Skip to main content
15,069,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I run debugging on VS2015. For a string s = "F1";
Suddenly, I got such an error in "Immediate Window", as shown below:
s.Contains("A")
Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized.
ar[0, 0].Substring(0, 1)
Cannot evaluate expression because the code of the current method is optimized.

What does it mean? How can it be resolved? Thanks.

What I have tried:

Error -
Cannot evaluate expression because the code of the current method is optimized
Posted
Updated 9-Sep-21 11:35am
Comments
Patrice T 9-Sep-21 16:18pm
   
What says Google ?
Richard Deeming 10-Sep-21 5:04am
   
Richard MacCutchan 10-Sep-21 6:08am
   
Since neither of those statements actually do anything useful, the compiler will not generate any object code for them. If you change the code so that you capture the result of each statement it should work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900