Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debugging program without VB

Status
Not open for further replies.

ComputersUnlimited

IS-IT--Management
Dec 18, 2013
37
US
The program that I have been working on is to the point where I am able to start running and testing it on other computers. It runs as intended on my notebook and desktop, however when I run it on a couple of other computers I get unhandled exception errors.

Is there a way to at least know at what line the error occurred, with out having to have Visual Basic installed?

Thank You
 
I second the StrongM's statement: exceptions need to be handled.
This is how I do it:

Code:
Try
   goSqlReader = goSqlCommand.ExecuteReader()
Catch loErr As Exception
   gcProcLog = gcProcLog & Now.ToString("yyyy-MM-dd HH:mm:ss") & ": ERROR OCCURED!" & vbCrLf & Space(21) & loErr.Message & _
               vbCrLf & Space(21) & "Occured in " & vbCrLf & Space(21) & loErr.Source & vbCrLf & Space(21) & loErr.StackTrace & _
               vbCrLf & Space(21) & "Program quits." & vbCrLf
   llGoOn = False
   Write2Log(gcLogFile, gcProcLog, True)
   goSqlCommand.Connection.Close()
   goSqlCommand.Dispose()
   lcErrStr = "ERROR OCCURED!" & vbCrLf & loErr.Message & vbCrLf & "Occured in " & vbCrLf & loErr.Source & vbCrLf & _
               loErr.StackTrace & vbCrLf & "Program quits."
End Try

If Not llGoOn Then
   MsgBox(lcErrStr, MsgBoxStyle.Critical, gcAppName)
   End
End If

Write2Log() proc does exactly that: writes to the process LOG (pure ASCII) file.
The rest of the memvars... well, is obvious, isn't it?
So, if you know approximately where the error might occur, just encapsulate it with TRY-CATCH-ENDTRY construct.
If error does occur, you just look up that LOG file and you will have some info about that error.
HTH.

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top