1

I have an application that writes/logs the Exception in the database. All codes works okay when I am using the Visual Studio to run the project. But when I compiled or when I created the installer and installed to my PC. The FileName and LineNumber is null.

I am using the code below:

 var sTrace = new StackTrace(sqlEx, true);
 if (sTrace != null)
  {
    // var frame = sTrace.GetFrame(sTrace.FrameCount - 1);
    var frame = sTrace.GetFrames().Last();
    LineNumber = frame.GetFileLineNumber();
    SrcFileName = frame.GetFileName();
    MethodName = frame.GetMethod().ReflectedType.FullName + "." + frame.GetMethod().Name;
  }
Zhyke
  • 427
  • 7
  • 22

1 Answers1

2

Debug builds tend to include *.pdb files, which include line number/file info. Typically, for a "production" or "installer" build you do not tend to output these files.

There is nothing stopping you include the pdb's with your installer if you want this information.

Jamiec
  • 133,658
  • 13
  • 134
  • 193
  • thanks, i tried configuring the project and it still not generating the .pdb file. I followed the answer in this link. https://stackoverflow.com/questions/628565/display-lines-number-in-stack-trace-for-net-assembly-in-release-mode – Zhyke Sep 05 '17 at 10:03
  • I already resolved it. I added the Debug Symbol in application Folder when creating the installer. Thanks. – Zhyke Sep 05 '17 at 10:11