Error Line Number Vb.net
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 About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges 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: Sign up Getting VB.NET line numbers in stack trace up vote 7 down vote favorite 4 I have a VB.NET 2010 Winforms application where I'd like to include line numbers in the stack trace. I've read the following question and answers: how to print out line number during application run in VB.net Which mentions "you always need to include the PDB file with your code, which contains debugging information that is used in situations like this". Under advanced compiler settings I've tried "Generate debug info" as "pdb-only" and "full" for my release build and confirmed that a fresh PDB file is generated in the same directory as my EXE. However the following test code generates a line number of zero for each stack frame and doesn't return a filename: Dim st As StackTrace = New StackTrace(ex) For Each sf As StackFrame In st.GetFrames MsgBox("Line " & sf.GetFileLineNumber() & sf.GetFileName) Next However the following code straight after it generates an otherwise good looking stack trace so it doesn't seem to be a problem with the exception handler in general: ExceptionDetails.Text = ex.GetType.ToString & "(0x" & hr.ToString("X8") & "): " & ex.Message & vbCrLf & ex.StackTrace I can't seem to find any other likely settings under the project configuration and wondered if anyone had ideas on other things that may cause this problem. All the solutions I've found searching here and elsewhere just seem to suggest making sure the PDB is in the same path as the executable. winforms stack-trace vb.net-2010 share|improve this question asked Dec 27 '12 at 0:06 PeterJ 2,14541732 add a comment| 3 Answers 3 active oldest votes up vote 4 down vote accepted From the documentation of the constructor you're calling: The StackTrace is created with the caller's curr
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Web Forms/VB.net: How to ALWAYS show the line number of the error VB.net: How to ALWAYS show the line number of the error [Answered]RSS 2 replies Last post Jun 21, 2012 03:41 PM by Nasser Malik ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Related Links GuidanceSamplesVideos Reply tvb2727 Participant 891 Points 2376 Posts VB.net: How to ALWAYS show the line number of http://stackoverflow.com/questions/14047821/getting-vb-net-line-numbers-in-stack-trace the error Jun 21, 2012 03:36 PM|tvb2727|LINK I am debugging a website I wrote. For some reason in my try/catch, it will show the error message, but no specific line # where the error occurred. How can I ALWAYS know the line # or what decides that? This is a .vb file. VB.net code Catch ex As Exception logging.errors(ex.ToString, http://forums.asp.net/t/1816998.aspx?VB+net+How+to+ALWAYS+show+the+line+number+of+the+error error_l) If HttpContext.Current.Session("where") = "cdrive" Then MsgBox(ex.ToString) End If Dim returnstring(0) As String returnstring(0) = False Return returnstring End Try Reply MattsDotNetU... Contributor 2151 Points 513 Posts Re: VB.net: How to ALWAYS show the line number of the error Jun 21, 2012 03:40 PM|MattsDotNetUsername|LINK You need to have the pdb file along with your DLL. Try running the website with those as well as your DLLsand you should see your line number. Reply Nasser Malik Star 12720 Points 2559 Posts Re: VB.net: How to ALWAYS show the line number of the error Jun 21, 2012 03:41 PM|Nasser Malik|LINK 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(); } see http://stackoverflow.com/questions/3328990/c-sharp-get-line-number-which-thrown-expection http://stackoverflow.com/questions/8338495
Forum Visual Basic Programming Visual Basic 6.0 Programming Getting the Line Number on a VB error If this is your first visit, be sure to check out the FAQ by clicking the link http://forums.codeguru.com/showthread.php?305265-Getting-the-Line-Number-on-a-VB-error above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: Getting the Line Number on a VB error Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded error line Mode August 6th, 2004,06:32 AM #1 Judgey View Profile View Forum Posts Member Join Date Mar 2001 Location County Durham, England Posts 238 Getting the Line Number on a VB error Hi All, Well my project has gone out to the public, 5 have sold, and already problems, I have tried to trap the errors, and its all fine and well getting the error number and description, but getting when its doing it out error line number of the user is a nightmare. surely there must be a way in Visual Basic you can get it to return the Line number the error is happening on ? Does anybody know how to achieve this ? Please, please, please, please help..... Reply With Quote August 6th, 2004,06:39 AM #2 Cimperiali View Profile View Forum Posts Elite Member Power Poster Join Date Jul 2000 Location Milano, Italy Posts 7,726 Code: private sub yoursub() On error goto ErrHandler dim sName as string dim iAge as integer 1: sName ="mario" 2: iAge =sname 3: msgbox "No mistake ? Or did you see a line number?" ErrHandler: msgbox err.description & vbcrlf & " Line of error:" & Erl resume 3 end sub ...at present time, using mainly Net 4.0, Vs 2010 Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus. Reply With Quote August 6th, 2004,06:40 AM #3 Cimperiali View Profile View Forum Posts Elite Member Power Poster Join Date Jul 2000 Location Milano, Italy Posts 7,726 (note: you can also skip the ":" after the number...) ...at present time, using mainly Net 4.0, Vs 2010 Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael