MSDN says this about the StackTrace
property of the Exception
class:
The StackTrace property holds a stack trace, which yo
Further to the other great suggestions, we were deploying to IIS. We had a staging server and a production server. They appeared identical except staging gave us line numbers and production did not. It turned out that there was an extra DLL in the bin directory of production (it happened to be SqlServerSpatial.dll fwiw) and once it was moved to the system directory line numbers started appearing on production.
The lesson was to ensure that the bin directory of production matches the bin directory of development in every respect (except for XML files).