How to get line numbers in exception stacktrace in production environment?

+1 vote
asked Aug 8, 2013 in VB.NET by Melwin

I am working on a legacy winforms application developed in Basically that application was developed inclassic vb and then directly converted into vb .net. So, it was not developed with well-formed architecture. So, we get so many exceptions in code which is happening in production environment. The application has logging functionality which stores the exception detail including stacktrace in sql server. But when we see those error logs, it is not providing clear information because we could not find the line number where it happens. The stacktrace simply says object null reference exception. That shows only the top level method. That parent method itself has 400 lines and it calls other methods inside. So, it is very hard to find the exact line number of the issue.

I have read in some articles that, we can get the line numbers in stack trace by deploying pdb files in production environment. But when I tried with pdbonly option, it did not give complete information. If anyone did deploy pdb file in production, could you please help me the steps you followed which gave you the exact line number in production environment?


1 Answer

+1 vote
answered Aug 8, 2013 by Aadhira (1,213 points)
selected Aug 8, 2013 by administrator
Best answer

Before I give you the solution for this issue, I would suggest you to not deploy using this steps in production. I would suggest you to use the approach for pilot version with very limited number of user. Because, pdb file is nothing but “Program DataBase” which has your code with additional attribute and details which help us to get the debug information.

The full version of pdb file will contain the debug information which will tell the JIT Compiler that debug information is available in the PDB file. So, this version is not suitable for production environment.

So, we have another version called pdb-only, which is almost same as full version without debug information. So, with pdbonly version, you can get complete stacktrace detail. Even for that, the compilation of the build must have done with “Enable Optimizations” unchecked.

1. Right click on all the projects in the solution and click on properties.
2. Go to, Compile tab.
3. Select Configuration as “Release”.
4. Click on “Advanced Compile Option” button at the bottom.
5. Uncheck “Enable Optimizations”
6. Select “pdb-only” option from the dropdown for “Generate debug info”
7. Click OK.
8. Now build the application and deploy pdb files with the exe and all your dll files.

Your answer


Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015