I have a function that get’s an exception (ex) and retrieves it’s details and then saves them into DB .
public static void NewLog(Exception ex, HowToLog option)
{
// retrive details of exception
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
string PageName = trace.GetFrame(trace.FrameCount - 1).GetFileName();
PageName = PageName.Substring(PageName.LastIndexOf("\\") + 1);
....
}
this works in local but on host when an error happens and this function tries to save it into DB an exception ” object refrence not set to an object ” on code below :
PageName = PageName.Substring(PageName.LastIndexOf("\\") + 1);
Looks like PageName was null..