C# – Add line numbers to stack trace of ASP.NET web site that is deployed in release mode


I working on maintenance of one web application, this web site having error log functionality as well.

My client occasionally face some issue on website which also logged in error log file but it shows only method calling hierarchy where exception occurred in stack trace.

When I explicitly raise exception on my Dev environment stack trace of exception shows method calling hierarchy and its line number from where actual exception has occurred.

I know in production we are deploying only DLLs that's why we are not getting error line number in log file.

Anybody has any Idea how can I get error line number as well in exception when we deployed DLL (assemblies) only?

Best Solution

In the build settings, set your project to generate debug symbols (pdb:s) in release mode too. If they are generated they will be automatically included on deploy. There is no need to run the entire site in debug mode, you just need the debug symbols available.

The setting is in the properties of the project. Select the build configuration you are using when publishing. Then on the Build tab, push the Advanced... button and set debug info to "Full".