1

Possible Duplicate:
C# Exceptions Not Giving Line Numbers

In C# winform, inside a catch block i have

Exception.ToString() -> to get exception information and line number of the code where the exception is thrown.

In dev. environment, i get the line number, whereas when the same EXE is deployed in the production, i don't get line numbers, any thoughts?

How do i get line #s in production environment? Even i tried StackTrace

class's GetFileLineNumber(), but it didn't bring me the line # in production environment.

Community
  • 1
  • 1
Sharpeye500
  • 8,775
  • 25
  • 95
  • 143
  • You need to post the code you are having problems with. as it stands the question does not make that much sense... – MoonKnight Sep 19 '12 at 15:44

2 Answers2

10

The file name and line number are only available if debug symbols are loaded for the code that throws the exception. These symbols are in the .pdb files, which are usually not deployed with the assemblies in the production environment. If you deploy these files, you should get the line number information in the stack trace.

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
0

You need to have the PDB file in the same directory as the application in order to get this kind of information. Release builds generally aren't meant for debugging however, so I don't know why you would need this information from a release build.

Jordan Kaye
  • 2,837
  • 15
  • 15
  • In many cases some problems are hard to reproduce in the debug environment (especially race conditions). Having a line number really helps. Having said that, refactoring your code so that one method has exactly one responsibility can also help identify what might be the problem. – akhisp Sep 19 '12 at 15:49