Is there any way to find out which object caused the NullReferenceException?
asp.net, c#
Solution
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();
Problem
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 or logging the object that was null?