Asp.net Error Line Numbers
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site c# exception stack trace line numbers About Us Learn more about Stack Overflow the company Business Learn more about c# get line number from exception without pdb hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join how to get exception line number in c# in release mode the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Add line numbers to stack
C# Stack Trace Line Numbers Wrong
trace of ASP.NET web site that is deployed in release mode up vote 6 down vote favorite 1 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 get line number from exception c# 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? c# asp.net .net exception pdb-files share|improve this question edited Nov 22 '13 at 6:28 asked Nov 19 '13 at 10:47 Neeraj Kumar Gupta 71431228 are you using log4net for logging? –CarbineCoder Nov 19 '13 at 10:54 build your project in Release mode and then stacktrace the exception. @Neeraj Kumar Gupta –Rezoan Nov 19 '13 at 10:57 1 It seems it will work I tried it in my PC with one sample application, but my actual application deployment process all done by client it self so if they built app in debug mode and deploy pdb file as well, will it cause any performence issue ? –Neeraj Kumar Gupta Nov 19 '13 at 10:57 @bharath no we are having our own error
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies how do i find the line number of exception in c# of this site About Us Learn more about Stack Overflow the company
Vb.net Exception Line Number
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Stack Trace Line Numbers Missing
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/20069409/add-line-numbers-to-stack-trace-of-asp-net-web-site-that-is-deployed-in-release Sign up C# - get line number which threw exception up vote 99 down vote favorite 33 In a catch block, how can I get the line number which threw an exception? c# exception share|improve this question edited Dec 4 '15 at 3:55 Mogsdad 24.4k955123 asked Jul 25 '10 at 11:25 MBZ 5,6251767133 at runtime there is no source code. http://stackoverflow.com/questions/3328990/c-sharp-get-line-number-which-threw-exception what this line no will be used for? at debug time, the IDE clearly shows line which throws exception. –ankitjaininfo Jul 25 '10 at 11:28 possible duplicate of Exception handling -- display line number where error occurred? –Fredrik Mörk Jul 25 '10 at 11:29 possible duplicate of Show line number in exception handling –Thom Smith Oct 25 '12 at 14:29 add a comment| 10 Answers 10 active oldest votes up vote 134 down vote accepted If you need the line number for more than just the formatted stack trace you get from Exception.StackTrace, you can use the StackTrace class: try { throw new Exception(); } catch (Exception ex) { // Get stack trace for the exception with source file information var st = new StackTrace(ex, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); } Note that this will only work if there is a pdb file available for the assembly. share|improve this answer answered Jul 25 '10 at 11:52 Quartermeister 32.6k67178 1 ?(New StackTrac
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Getting Started/Obtaining exception line number using Server.GetLastError Obtaining exception line number using Server.GetLastError [Answered]RSS 12 replies Last post Aug 06, 2009 10:36 AM http://forums.asp.net/t/1302019.aspx?Obtaining+exception+line+number+using+Server+GetLastError by mikeg@ar ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply Rouchie Member 66 Points 349 Posts Obtaining exception line http://www.justskins.com/forums/error-line-number-22298.html number using Server.GetLastError Aug 07, 2008 04:40 AM|Rouchie|LINK I currently have a custom error page in my application that automatically emails me with any errors that occur. To get the error details line number I do something like this: Dim ex As Exception = HttpContext.Current.Server.GetLastError() If TypeOf ex Is HttpUnhandledException AndAlso ex.InnerException IsNot Nothing Then ex = ex.InnerException End If If ex IsNot Nothing Then Dim s As New StringBuilder s.AppendLine("Message:" & Environment.NewLine & ex.Message & Environment.NewLine) s.AppendLine("Source:" & Environment.NewLine & ex.Source & Environment.NewLine) s.AppendLine("Stack Trace:" & Environment.NewLine & ex.StackTrace) ' ... email code here ... End If stack trace line I realised today however that it would be much more useful to also have the filename of the misbehaving page, plus the line number. Currently this is not within the stack trace where I thought it would be. Can anyone advise how I can include this information? Thanks. Reply santa_1975 Contributor 5601 Points 1490 Posts Re: Obtaining exception line number using Server.GetLastError Aug 07, 2008 04:59 AM|santa_1975|LINK You can use the StackTrace and StackFrame from the System.Diagnostics as below. StackTrace st = new StackTrace(new StackFrame(true)); StackFrame sf = st.GetFrame(0); Console.WriteLine("File Name: {0}", sf.GetFileName()); Console.WriteLine("Method Name: {0}", sf.GetMethod().Name); Console.WriteLine("Error Line Number: {0}", sf.GetFileLineNumber()); Console.WriteLine("Error Column Number: {0}", sf.GetFileColumnNumber());Hope this helps. Please remember to click “Mark as Answer” on the post that helps you and to unmark it if a marked post does not actually answer your question. Thank you! ---------------------- "Microsoft Community Contributor Award 2011" Reply Rouchie Member 66 Points 349 Posts Re: Obtaining exception line number using Server.GetLastError Aug 07, 2008 06:31 AM|Rouchie|LINK HI Will this code work with ASP.NET? StackTrace does not appear in Intellisense as a variable type for me... Reply Thomas Sun –... All-Star 54916 Points 5597 Posts Re: O
Newsgroup, A very short question: If have a try/catch structure. In the catch part I would like to get the line number where the exception has occured? Can I get this information and if so how? Regards, Sune... Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode July 1st,08:41 AM #1 Error line number Hi Newsgroup, A very short question: If have a try/catch structure. In the catch part I would like to get the line number where the exception has occured? Can I get this information and if so how? Regards, Sune Sune Hansen Guest July 1st,08:50 AM #2 Re: Error line number As far as I know; after compilation, errors won't show line numbers because, they're not in Source Code form. There may be some difference in CLR that I don't know. Serdar KALAYCI "Sune Hansen"