1

I have a SomeNameController.cs file in App_Code. In this cs file, I have a piece of code in try-catch block. Inside catch block I am trying to log the exception, but when an exception is logged (ex:Object reference not set to an instance of an object.), I cannot find in which line number this occurred as we normally get in stack trace.

catch (Exception ex) {
    string errorMsg = string.Format("[SomeNameController][Save]- Msg: {0}", ex.ToString());
    LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, errorMsg, ex);
}

Note: I don't have pdb file for this as this file is in App_Code

Yannick Meeus
  • 5,643
  • 1
  • 35
  • 34
Cijo V J
  • 261
  • 1
  • 3
  • 14
  • Here is a good answer from adrianbanks: http://stackoverflow.com/questions/3791696/how-to-get-line-numbers-in-the-stacktrace-of-an-exception-thrown-in-net-to-sh – TailorDurden Nov 01 '16 at 05:04
  • I had seen the answer in above link but, it is related to PDB file and my code is in App_Code, so I am not sure if it is of any help to me – Cijo V J Nov 01 '16 at 05:07
  • 1
    [Solved]. Debug = "true" in web config – Cijo V J Nov 01 '16 at 05:52

0 Answers0