Jay:
Thanks again for your reply and your patience with me as I try to figure
this out. I have the routine working now as I had hoped - well almost.
I will have a "home run" if there is a way to get the program and line
number that caused the crash when the program is run on client machines.
I passed the entire System.Threading.ThreadExceptionEventArgs to the
logexception subroutine.
When I run the program in debug mode on my development machine I get the
program name and line numbers from
ex.Exception.StackTrace.ToString.
When I run on any other machine - even with the code in debug mode - I do
get information however it does not contain the information that I need
most - line # and form name.
Is it possible to obtain this information?
Thanks again for your help!
Fred
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:uup%23ANSvEHA.536@TK2MSFTNGP11.phx.gbl...[color=blue]
> Fred,
> As I stated:
>[color=green][color=darkred]
> >> For example: In my Windows Forms apps I would have a handler attached[/color][/color][/color]
to[color=blue][color=green]
> > the[color=darkred]
> >> Application.ThreadException event,[/color][/color]
>
> The link I gave goes into further details.
>
> Something like:
>
> Public Module MainModule
>
> Public Sub Main
> AddHandler Application.ThreadException, AddressOf
> Application_ThreadException
> Try
> Application.Run(New LetterPrintForm)
> Catch ex As Exception
> LogException(ex)
> End Try
> End Sub
>
> Private Sub Application_ThreadException(ByVal sender As Object,
> ByVal e As System.Threading.ThreadExceptionEventArgs)
> LogException(e.Exception)
> End Sub
>
> Private Sub LogException(ByVal ex As Exception)[color=green]
> > ** code that writes error to an sql database[/color]
> End Sub
>
> Hope this helps
> Jay
>
> "Fred Nelson" <fred@smartybird.com> wrote in message
> news:eNV%2337RvEHA.3612@TK2MSFTNGP09.phx.gbl...[color=green]
> > Jay:
> >
> > I "almost" have it working.
> >
> > My program starts with a Main as follows:
> >
> > --------------
> > Public Module main
> >
> > Public Sub main()
> >
> >
> >
> > Try
> >
> > Application.Run(New letterprint)
> >
> > Catch ex As Exception
> >
> > ** code that writes error to an sql database
> >
> > -------------------
> >
> > Now the catch: it works just fine if I'm in the development environment.
> > When I compile the program in either debug or release mode and have an
> > error
> > I get a pop-up dialog box:
> >
> > An unhandled Exception Error has occurred in your application. If yoiu
> > click continue, the application will ignore this error and attempt to
> > continue.
> >
> > If folks continue the program returns to the next line as though no[/color][/color]
error[color=blue][color=green]
> > happened.
> >
> > Is there additional code that I must put into the forms that will[/color][/color]
prevent[color=blue][color=green]
> > this from happening - I just need to write the error to my SQL database
> > and
> > terminate the program.
> >
> > Once again your help is GREATLY appreciated!
> >
> > Fred
> >
> >
> >
> >
> > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:uWknSMRvEHA.4072@TK2MSFTNGP15.phx.gbl...[color=darkred]
> >> Fred,
> >> > I'm trying to implement an overall error handler in my VB.NET windows
> >> > application.
> >> In addition to the other comments:
> >>
> >> Depending on the type of application you are creating, .NET has three
> >> different global exception handlers.
> >>
> >> For ASP.NET look at:
> >> System.Web.HttpApplication.Error event
> >> Normally placed in your Global.asax file.
> >>
> >> For console applications look at:
> >> System.AppDomain.UnhandledException event
> >> Use AddHandler in your Sub Main.
> >>
> >> For Windows Forms look at:
> >> System.Windows.Forms.Application.ThreadException event
> >> Use AddHandler in your Sub Main.
> >>
> >> It can be beneficial to combine the above global handlers in your app,[/color][/color][/color]
as[color=blue][color=green][color=darkred]
> >> well as wrap your Sub Main in a try catch itself.
> >>
> >> There is an article in the June 2004 MSDN Magazine that shows how to
> >> implement the global exception handling in .NET that explains why &[/color][/color][/color]
when[color=blue][color=green]
> > you[color=darkred]
> >> use multiple of the above handlers...
> >>
> >>
http://msdn.microsoft.com/msdnmag/is...T/default.aspx
> >>
> >> For example: In my Windows Forms apps I would have a handler attached[/color][/color][/color]
to[color=blue][color=green]
> > the[color=darkred]
> >> Application.ThreadException event, plus a Try/Catch in my Main. The
> >> Try/Catch in Main only catches exceptions if the constructor of the[/color]
> > MainForm[color=darkred]
> >> raises an exception, the Application.ThreadException handler will catch[/color]
> > all[color=darkred]
> >> uncaught exceptions from any form/control event handlers.
> >>
> >> Hope this helps
> >> Jay
> >>[/color][/color]
> <<snip>>
>
>[/color]