Function evaluation timed out when examining variables in debug/stepping through

前端 未结 2 1536
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 10:48

When debugging/stepping through code, and I try to examine a variable in the watch, I get errors for every inner-variable stating function evaluation timed out.

Does

相关标签:
2条回答
  • 2021-01-01 11:44

    The most likely cause of this problem is an implicit evaluation of a property or ToString method which causes an issue with the CLR evaluation thread. To verify this turn off implicit evaluation.

    • Tools -> Options
    • Debugging
    • Uncheck "Enable property evaluation and other implicit function calls"

    Then restart your scenario and see if it works.

    0 讨论(0)
  • 2021-01-01 11:45

    Visual studio executes the property getter to get its value, if it takes a long time either because its doing something expensive you get this error. consider:

    public class foo
    {
        private object lockObject = new object();
        public int bar
        {
            get
            {
                 lock(lockObject){
                    return 42;
                 }
             }
         }
         public int aMethod()
         {
             lock(lockObject)
             {
                 var a = this.bar;
                 return a*2;   //insert a break point here
              }
          }
    }
    

    If you add a break point on the return statement in aMethod the debugger will not be able to evaluate the bar property, because doing so requires that it acquires the lock object, but it won't be able to do so because the program will hold that lock forever while the break point is active

    0 讨论(0)
提交回复
热议问题