I need a suggestion regarding Object reference issue. I got this message ExceptionMessage: Object reference not set to an instance of an object. (because some null object) I am printing the stack trace when an error occurs:
Exception systemException = lastError.GetBaseException();
By using ex.Message I am able to get the method where exception has occurred but I am not getting any information regarding the line (of that method) where exception occurred. I need to know at which line object reference has occurred and which object was null when this exception came.
That line number is pretty much guaranteed to be in the stack trace. If you want to drill down on it, put a try-catch in the large block of code where it might be happening and drop a breakpoint on the catch block, which will allow you to drop down through the InnerExceptions inside of visual studio (if any exist).