Is there any way to find out which object caused the NullReferenceException?

后端 未结 3 1592
独厮守ぢ
独厮守ぢ 2021-01-12 13:14

Is there any way to find the object name that caused the control to flow into the catch block from a NullReferenceException, so that we can easily debug by giving an alert o

3条回答
  •  既然无缘
    2021-01-12 13:58

    No.
    You only get the stack trace including line numbers.
    This helps you in simple cases like this:

    var result = myString.Trim();
    

    But it doesn't help in lines like this:

    var result = myObj.Method1().Method2();
    

提交回复
热议问题