![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Unhandled Exception in Console Application Can anyone point me to an example or info on handling unhandled exceptions in a console application? Preferrably VB. Thanks, -- AG Email: discussATadhdataDOTcom |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Unhandled Exception in Console Application On Tue, 08 Apr 2008 13:34:30 -0700, AG <NOSPAMagiamb@xxxxxx> wrote: Quote: > Can anyone point me to an example or info on handling unhandled > exceptions > in a console application? > Preferrably VB. of information and a code sample: http://msdn2.microsoft.com/en-us/lib...exception.aspx |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Unhandled Exception in Console Application Thanks for the quick reply. That looks good. I will try it. -- AG Email: discussATadhdataDOTcom "Peter Duniho" <NpOeStPeAdM@xxxxxx> wrote in message news p.t9banlie8jd0ej@xxxxxx-computer.local...Quote: > On Tue, 08 Apr 2008 13:34:30 -0700, AG <NOSPAMagiamb@xxxxxx> > wrote: > Quote: >> Can anyone point me to an example or info on handling unhandled >> exceptions >> in a console application? >> Preferrably VB. > The MSDN documentation for the AppDomain.UnhandledException event has lots > of information and a code sample: > http://msdn2.microsoft.com/en-us/lib...exception.aspx |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Unhandled Exception in Console Application That enables me to log the exception, but how can I prevent the Windows 'Myapp has encountered a problem and needs to close...' dialog from popping up? -- AG Email: discussATadhdataDOTcom "Peter Duniho" <NpOeStPeAdM@xxxxxx> wrote in message news p.t9banlie8jd0ej@xxxxxx-computer.local...Quote: > On Tue, 08 Apr 2008 13:34:30 -0700, AG <NOSPAMagiamb@xxxxxx> > wrote: > Quote: >> Can anyone point me to an example or info on handling unhandled >> exceptions >> in a console application? >> Preferrably VB. > The MSDN documentation for the AppDomain.UnhandledException event has lots > of information and a code sample: > http://msdn2.microsoft.com/en-us/lib...exception.aspx |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Unhandled Exception in Console Application you can try if (Args.IsTerminating) Environment.Exit (0) ; where Args is your UnhandledExceptionEventArgs /LM "AG" <NOSPAMagiamb@xxxxxx> wrote in message news:%23GQmlQkmIHA.5268@xxxxxx Quote: > That enables me to log the exception, but how can I prevent the Windows > 'Myapp has encountered a problem and needs to close...' dialog from > popping up? > > -- > > AG > Email: discussATadhdataDOTcom > "Peter Duniho" <NpOeStPeAdM@xxxxxx> wrote in message > news p.t9banlie8jd0ej@xxxxxx-computer.local...Quote: >> On Tue, 08 Apr 2008 13:34:30 -0700, AG <NOSPAMagiamb@xxxxxx> >> wrote: >> Quote: >>> Can anyone point me to an example or info on handling unhandled >>> exceptions >>> in a console application? >>> Preferrably VB. >> The MSDN documentation for the AppDomain.UnhandledException event has >> lots of information and a code sample: >> http://msdn2.microsoft.com/en-us/lib...exception.aspx > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Unhandled Exception in Console Application On Wed, 09 Apr 2008 06:18:04 -0700, AG <NOSPAMagiamb@xxxxxx> wrote: Quote: > That enables me to log the exception, but how can I prevent the Windows > 'Myapp has encountered a problem and needs to close...' dialog from > popping up? chance it'll work (I'd test it myself, but I figure you can do that just as easily, and at the moment I am doing other things ).If it doesn't, then you may not be able to prevent the dialog from appearing. Of course, this assumes the exception is happening somewhere that you are unable to provide your own try/catch block in order to handle the exception. Your original question implies this, but if it's not really true, then obviously the best solution is to actually handle the exception. ![]() Pete |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Unhandled Exception in Console Application Thanks both. That works. I haven't done a console app before and It is a very small one. I could easily have wrapped that whole thing in a try/catch, but this way I learned much more .-- AG Email: discussATadhdataDOTcom "Luc E. Mistiaen" <luc.mistiaen@xxxxxx> wrote in message news:e6$YxLlmIHA.5260@xxxxxx Quote: > you can try > if (Args.IsTerminating) Environment.Exit (0) ; > > where Args is your UnhandledExceptionEventArgs > > /LM > > "AG" <NOSPAMagiamb@xxxxxx> wrote in message > news:%23GQmlQkmIHA.5268@xxxxxx Quote: >> That enables me to log the exception, but how can I prevent the Windows >> 'Myapp has encountered a problem and needs to close...' dialog from >> popping up? >> >> -- >> >> AG >> Email: discussATadhdataDOTcom >> "Peter Duniho" <NpOeStPeAdM@xxxxxx> wrote in message >> news p.t9banlie8jd0ej@xxxxxx-computer.local...Quote: >>> On Tue, 08 Apr 2008 13:34:30 -0700, AG <NOSPAMagiamb@xxxxxx> >>> wrote: >>> >>>> Can anyone point me to an example or info on handling unhandled >>>> exceptions >>>> in a console application? >>>> Preferrably VB. >>> >>> The MSDN documentation for the AppDomain.UnhandledException event has >>> lots of information and a code sample: >>> http://msdn2.microsoft.com/en-us/lib...exception.aspx >> > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Unhandled Exception in Console Application Luc E. Mistiaen wrote: Quote: > you can try > if (Args.IsTerminating) Environment.Exit (0) ; > > where Args is your UnhandledExceptionEventArgs > appdomains, and it will also prevent you from diagnosing the unhandled exception under a debugger (you can set a breakpoint on the event callback, but that isn't convenient at all). Finally, the usual step of writing an error to the event log will be skipped. I also suggest passing a non-zero value to Environment.Exit(), since processes that check the exit status (if any) will usually interpret a zero exit status as success, which is a tad misleading. In short, I'm not at all happy that this actually works. :-) -- J. |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Unhandled Exception in Console Application Thanks for the info. In this case it will be fine as the app is just for my own use. However, I am interested in how you think it should be handled. -- AG Email: discussATadhdataDOTcom "Jeroen Mostert" <jmostert@xxxxxx> wrote in message news:47fd20a7$0$14342$e4fe514c@xxxxxx Quote: > Luc E. Mistiaen wrote: Quote: >> you can try >> if (Args.IsTerminating) Environment.Exit (0) ; >> >> where Args is your UnhandledExceptionEventArgs >> > appdomains, and it will also prevent you from diagnosing the unhandled > exception under a debugger (you can set a breakpoint on the event > callback, but that isn't convenient at all). Finally, the usual step of > writing an error to the event log will be skipped. > > I also suggest passing a non-zero value to Environment.Exit(), since > processes that check the exit status (if any) will usually interpret a > zero exit status as success, which is a tad misleading. > > In short, I'm not at all happy that this actually works. :-) > > -- > J. |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Unhandled Exception in Console Application > Finally, the usual step of writing an error to the event log will be Quote: > skipped. just do it before exiting. Quote: > > I also suggest passing a non-zero value to Environment.Exit(), since > processes that check the exit status (if any) will usually interpret a > zero exit status as success, which is a tad misleading. Quote: > > In short, I'm not at all happy that this actually works. :-) would have much preferred some boolean to be set in the argument object to tell the run-time I handled to event to my taste (knowing that the program would terminate anyway). /LM |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Microsoft .NET Framework Unhandled exception...... | General Discussion | |||
Unhandled Exception has occured in your application | General Discussion | |||
| Unhandled exception 0xC0000005 in migcore.dll when upgrading to Vi | Vista General | |||