Using the code below in Debug I get the info I want which is basically:
-Line of error
-Column of error
-Method where error happened
However, when you compile to Release version you get no line or column
numbers. So I assume this is because the .pdb file holds all of the info
regarding the lines and columns or something to that order. I am not
really to sure what the .pdb file actually holds.
So what I am after is a way to track down the exact place the error
happened without having to put a try...catch block everywhere in my
code. Am I going about this all wrong?
Also please note the code below is simply me playing and is in no way
complete or even ready for release. Also I should note that I am running
this by pressing F5 in VS.Net 2003 with DotNet Framework 1.1.
TIA
-Stanley
Expand|Select|Wrap|Line Numbers
- Imports System.Diagnostics
- Public Class _default
- Inherits System.Web.UI.Page
- #Region " Web Form Designer Generated Code "
- 'This call is required by the Web Form Designer.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub
- InitializeComponent()
- End Sub
- 'NOTE: The following placeholder declaration is required by the Web
- Form Designer.
- 'Do not delete or move it.
- Private designerPlaceholderDeclaration As System.Object
- Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
- System.EventArgs) Handles MyBase.Init
- 'CODEGEN: This method call is required by the Web Form Designer
- 'Do not modify it using the code editor.
- InitializeComponent()
- End Sub
- #End Region
- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
- System.EventArgs) Handles MyBase.Load
- Dim a As Integer = 0
- Dim b As Integer
- Try
- b = 1 \ a
- Catch ex As Exception
- Dim sf As New StackFrame(True)
- Dim st As New StackTrace(sf)
- Response.Write(ex.ToString.Replace(vbCrLf, "<br>"))
- Response.Write("<br>")
- Response.Write("Line #: " & st.GetFrame(0).ToString())
- Response.Write("<br>")
- Response.Write("Line #: " & st.GetFrame(0).GetFileLineNumber())
- Response.Write("<br>")
- Response.Write("Column #: " &
- st.GetFrame(0).GetFileColumnNumber())
- Response.Write("<br>")
- Response.Write("Method : " & st.GetFrame(0).GetMethod().Name)
- End Try
- End Sub
- End Class
System.DivideBy ZeroException: Attempted to divide by zero.
at pcTracker._defa ult.Page_Load(O bject sender, EventArgs e) in
C:\Inetpub\wwwr oot\pcTracker\d efault.aspx.vb: line 28
Line #: Page_Load at offset 131 in file:line:colum n
C:\Inetpub\wwwr oot\pcTracker\d efault.aspx.vb: 30:17
Line #: 30
Column #: 17
Method : Page_Load
[/debug results]
[release results]
System.DivideBy ZeroException: Attempted to divide by zero.
at pcTracker._defa ult.Page_Load(O bject sender, EventArgs e)
Line #: Page_Load at offset 128 in file:line:colum n :0:0
Line #: 0
Column #: 0
Method : Page_Load
[/release results]