user1040638
user1040638

Reputation: 23

How to find line # of code that this error occurs?

My asp.net website logs errors when they occur, but only sometimes shows the line of code where it occurred. Is there a way to find out what line of code my error is occuring on when the line is not provided?

My Global.asax logs the error with the following code:

   Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
    'Get MemberNumber
    Dim MemberNumber As String
    MemberNumber = User.Identity.Name.ToString
    If Len(User.Identity.Name.ToString) < 1 Then
        MemberNumber = "Guest"
    End If

    ' Code that runs when an unhandled error occurs
    Dim objErr As Exception = Server.GetLastError().GetBaseException()

    Dim ErrorDescription As String = "<b>Error Caught in Page_Error event</b><hr><br>" & _
 "<br><b>Member:</b> " & MemberNumber & _
 "<br><b>Error in: </b>" & Request.Url.ToString() & _
 "<br><b>Source Error:</b><br>" & objErr.Source.ToString() & _
 "<br><b>Error Message: </b>" & objErr.Message.ToString() & _
 "<br><b>Stack Trace:</b><br>" & _
 objErr.StackTrace.ToString()

    ErrorDescription = ErrorDescription & "<br />&nbsp;<br /><b>Form Variables</b>"
    For Each x As String In Request.Form
        If Trim(Request.Form(x).ToString).Contains("__VIEWSTATE") = False Then ErrorDescription = ErrorDescription & (x & ": ") & Request.Form(x) & "<br />"
    Next

'LOG ERROR cms.Application_Error_Log_Add(ErrorDescription) End Sub

I am trying to find the line on which the error occurs for this:

Source Error: Microsoft.VisualBasic
Error Message: Input string was not in a correct format.
Stack Trace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)

Form Variables__EVENTTARGET: ctl00$ContentPlaceHolder1$SchoolQuestions$ckAdmin __EVENTARGUMENT: ctl00_RadScriptManager1_TSM: ;;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:en-US:94b8a2b4-5efc-4f4c-9641-d912b698978d:ea597d4b:b25378d2;Telerik.Web.UI, Version=2010.3.1317.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4:en-US:4818cc11-a19b-4572-9f4d-207fcad19ad2:16e4e7cd:b7778d6c:e085fe68 __LASTFOCUS: __VIEWSTATE: ctl00$ContentPlaceHolder1$SchoolQuestions$ddSchoolID: 92 ctl00$ContentPlaceHolder1$SchoolQuestions$ckAdmin: on ctl00$ContentPlaceHolder1$SchoolQuestions$tMyName: ctl00$ContentPlaceHolder1$SchoolQuestions$tLast: ctl00_ContentPlaceHolder1_SchoolQuestions_tEventID_ClientState: {"enabled":true,"emptyMessage":"","minValue":0,"maxValue":70368744177664} __EVENTVALIDATION: /wEWQQL+raDpAgLh8t3iBgK25MzWDwL+zrvtDAK7i6q7AwK8i5q7AwKui6a7AwK9i667AwK6i5K7AwK5i567AwK5i5q7AwK7i8a4AwK5i4K7AwK4i5K7AwK/i567AwK5i5K7AwK9i5q7AwK4i4K7AwK8i6a7AwK/i8q4AwK/i5q7AwK9i567AwKui667AwK8i8a4AwK8i667AwK8i567AwK4i5q7AwK9i6a7AwK4i6a7AwK6i6a7AwK6i5a7AwK4i667AwK7i5a7AwK8i6q7AwK5i6q7AwK9i8a4AwK6i8a4AwK5i8a4AwK7i4K7AwK/i6q7AwK/i4K7AwK/i667AwK8i4K7AwK9i5a7AwK9i4K7AwK8i8q4AwK/i5K7AwK/i8a4AwK8i5a7AwKui6q7AwK/i5a7AwK/i6a7AwK4i5a7AwK8i5K7AwK4i6q7AwK9i6q7AwK5i667AwKY7+DxBgKbn7baCAK/qaGzCwLO8djHDQKroLz/DgLHmuLYBwLdl66XDgKbip7xDmPB2eQq30MMK1HtYTBNYWWD7h+z

It looks like the checkbox labeled "ckAdmin" is causing this error, but I do not know how to trace it. How should I go about tracing down this error or finding the line of the code this error occurs in?

Upvotes: 1

Views: 579

Answers (1)

Scott Hanselman
Scott Hanselman

Reputation: 17692

I suppose you could poke around in StackFrame, but that assumes that information is available (not running Release without Symbols, etc). Why not use ELMAH?

Upvotes: 1

Related Questions