Exception Line Number

Hi

I have this code

Public Sub LogError(ByVal TheException As Exception, ByVal LogFile As String)
        Dim LnNo As Integer = 0
        Dim Prog As String = ""
        Dim Proc As String = ""

        Try
            LnNo = New StackTrace(TheException, 0, True).GetFrame(1).GetFileLineNumber()
            Prog = New StackTrace(TheException, 0, True).GetFrame(1).GetMethod.DeclaringType.FullName
            Proc = New StackTrace(TheException, 0, True).GetFrame(1).GetMethod.Name

            My.Computer.FileSystem.WriteAllText(LogFile, Now() & "  L  " & Prog & " - " & Proc & "     Ln: " & LnNo & " :   " & TheException.Message & vbCrLf, True)

        Catch ex As Exception
            MessageBox.Show(TheException.Message, "Error In LogError 2") 'Show the user their error not mine
        End Try
    End Sub


it basically shows me where an error occured. It works great but then I read that the debug information is not available in release mode, which means that if someone else is running the program and gets an error the Line Number will not be shown.

on the following link it tells you how to include dubug info when you build in 2003
http://www.knowdotnet.com/articles/linenumbersinreleasemode.html

I cannot find this option in 2005. So I guess I am looking for an answer that tells me how to do this or another way of showing you what line the error occured when it gets one.


hope this is clear
Thanks
LVL 1
EamonAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
1) Do you see the Compile tab on the Project properties?

2) Here is a screenshot:

https://filedb.experts-exchange.com/incoming/ee-stuff/147-Advanced-Compiler-Settings.PNG 

Bob
0
 
EamonAuthor Commented:
Hi Bob

Yes I see the Compile tab but is there an option to Generate debugging information ?
0
 
Bob LearnedCommented:
Did you look at the screen shot?

Bob
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
EamonAuthor Commented:
Yes I those settings are default but when i run my program on another machine and get an exception the line number is not shown. Do I need to change generate debug info to FULL
0
 
Bob LearnedCommented:
From the Advanced Compiler Settings:

  Generate debug info:
     Full

Bob
0
 
EamonAuthor Commented:
did not seem to work. line number still not showing
0
 
Bob LearnedCommented:
Is the .pdb file located where the .exe is running from?

Bob
0
 
EamonAuthor Commented:
no its not there are 2 dlls that i created and the exe but thats it.
0
 
Bob LearnedCommented:
You need to have the .pdb located where the .exe is in order to get line numbers.  Normally, when you build in Release configuration, the .pdb file doesn't get built.  That project configuration setting controls the generation of the .pdb file.  Normally when you get an error that you are trying to debug, you keep a copy of the .pdb files in a place that indicates what version of the assembly it was built against, and then you can copy that file to the deployed application's folder, and get debugging information.

Bob
0
 
EamonAuthor Commented:
I set the install project to include the .pdb file. Now when I install the .pdb is there with the exe but when I run it it still does not show me the line numbers
0
 
Bob LearnedCommented:
Does the complete StackTrace show line numbers?

   ex.ToString()

Bob
0
 
EamonAuthor Commented:
no
0
 
EamonAuthor Commented:
It is working now.
I was including the .pdb from the release folder when I should have been including it from the debug folder.

To be honest I don't fully understand what is going on but at least it is working.

Thanks for all the help Bob.
0
All Courses

From novice to tech pro — start learning today.