Home All Groups Group Topic Archive Search About

Windows Form Level Exception

Author
27 Jul 2006 7:54 AM
Angelina
Is there anything similar to "Error" event of System.Web.UI.Page of Webforms
in a Windows Forms?? I want to catch all errors occured in a windows form? I
already know there is Application.ThreadException but that is on application
level.

- angi

Author
27 Jul 2006 9:06 AM
Dmytro Lapshyn [MVP]
Hi Angelina,

No, there's nothing like that in Windows Forms, as far as I know. Actually,
you should think of such global handlers only as of a "safety net" that
prevents the whole app from a nasty crash if bad things happen.

My recommendation is to have exception handlers everywhere an exception can
occur. It's OK to have a reusable procedure responsible for displaying error
messages, but catch errors as close to the place they occur as possible.
With this strategy, you should be able to gracefully deal with many errors
without even having to display any message to the user.

--
Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

Show quote
"Angelina" <me.angel***@yahoo.com> wrote in message
news:udDkEFVsGHA.4420@TK2MSFTNGP04.phx.gbl...
> Is there anything similar to "Error" event of System.Web.UI.Page of
> Webforms in a Windows Forms?? I want to catch all errors occured in a
> windows form? I already know there is Application.ThreadException but that
> is on application level.
>
> - angi
>
Author
27 Jul 2006 11:57 AM
Angelina
Hi Dmytro,

Thanx for the answer. The thing you told below is already used in my
application. I was just trying to figure out more secure approach to be on
safer side. But anyways thanx for anwering this and my previous queries too
Show quote
:)

"Dmytro Lapshyn [MVP]" <x-code@no-spam-please.hotpop.com> wrote in message
news:e51s6vVsGHA.4872@TK2MSFTNGP02.phx.gbl...
> Hi Angelina,
>
> No, there's nothing like that in Windows Forms, as far as I know.
> Actually, you should think of such global handlers only as of a "safety
> net" that prevents the whole app from a nasty crash if bad things happen.
>
> My recommendation is to have exception handlers everywhere an exception
> can occur. It's OK to have a reusable procedure responsible for displaying
> error messages, but catch errors as close to the place they occur as
> possible. With this strategy, you should be able to gracefully deal with
> many errors without even having to display any message to the user.
>
> --
> Regards,
> Dmytro Lapshyn [MVP]
> http://blogs.vbcity.com/DmytroL
>
> "Angelina" <me.angel***@yahoo.com> wrote in message
> news:udDkEFVsGHA.4420@TK2MSFTNGP04.phx.gbl...
>> Is there anything similar to "Error" event of System.Web.UI.Page of
>> Webforms in a Windows Forms?? I want to catch all errors occured in a
>> windows form? I already know there is Application.ThreadException but
>> that is on application level.
>>
>> - angi
>>
>
Author
27 Jul 2006 12:11 PM
Patrice
Try AppDomain.CurrentDomain.UnhandledException and/or
Application.ThreadException

--
Patrice

"Angelina" <me.angel***@yahoo.com> a écrit dans le message de news:
e0yFGNXsGHA.3***@TK2MSFTNGP06.phx.gbl...
Show quote
> Hi Dmytro,
>
> Thanx for the answer. The thing you told below is already used in my
> application. I was just trying to figure out more secure approach to be on
> safer side. But anyways thanx for anwering this and my previous queries
> too :)
>
> "Dmytro Lapshyn [MVP]" <x-code@no-spam-please.hotpop.com> wrote in message
> news:e51s6vVsGHA.4872@TK2MSFTNGP02.phx.gbl...
>> Hi Angelina,
>>
>> No, there's nothing like that in Windows Forms, as far as I know.
>> Actually, you should think of such global handlers only as of a "safety
>> net" that prevents the whole app from a nasty crash if bad things happen.
>>
>> My recommendation is to have exception handlers everywhere an exception
>> can occur. It's OK to have a reusable procedure responsible for
>> displaying error messages, but catch errors as close to the place they
>> occur as possible. With this strategy, you should be able to gracefully
>> deal with many errors without even having to display any message to the
>> user.
>>
>> --
>> Regards,
>> Dmytro Lapshyn [MVP]
>> http://blogs.vbcity.com/DmytroL
>>
>> "Angelina" <me.angel***@yahoo.com> wrote in message
>> news:udDkEFVsGHA.4420@TK2MSFTNGP04.phx.gbl...
>>> Is there anything similar to "Error" event of System.Web.UI.Page of
>>> Webforms in a Windows Forms?? I want to catch all errors occured in a
>>> windows form? I already know there is Application.ThreadException but
>>> that is on application level.
>>>
>>> - angi
>>>
>>
>
>
Author
27 Jul 2006 12:43 PM
oscar.acostamontesde@googlemail.com
try placing a try-catch block where you instanciate you form, like:
try{
Form my = new Form();
my.Show();
......
}catch(Exception e){}

I use AppDomain.CurrentDomain.UnhandledException in the Program class,
even if a read an article about not all exceptions bee caugth with this
handler.

Patrice ha escrito:

Show quote
> Try AppDomain.CurrentDomain.UnhandledException and/or
> Application.ThreadException
>
> --
> Patrice
>
> "Angelina" <me.angel***@yahoo.com> a écrit dans le message de news:
> e0yFGNXsGHA.3***@TK2MSFTNGP06.phx.gbl...
> > Hi Dmytro,
> >
> > Thanx for the answer. The thing you told below is already used in my
> > application. I was just trying to figure out more secure approach to be on
> > safer side. But anyways thanx for anwering this and my previous queries
> > too :)
> >
> > "Dmytro Lapshyn [MVP]" <x-code@no-spam-please.hotpop.com> wrote in message
> > news:e51s6vVsGHA.4872@TK2MSFTNGP02.phx.gbl...
> >> Hi Angelina,
> >>
> >> No, there's nothing like that in Windows Forms, as far as I know.
> >> Actually, you should think of such global handlers only as of a "safety
> >> net" that prevents the whole app from a nasty crash if bad things happen.
> >>
> >> My recommendation is to have exception handlers everywhere an exception
> >> can occur. It's OK to have a reusable procedure responsible for
> >> displaying error messages, but catch errors as close to the place they
> >> occur as possible. With this strategy, you should be able to gracefully
> >> deal with many errors without even having to display any message to the
> >> user.
> >>
> >> --
> >> Regards,
> >> Dmytro Lapshyn [MVP]
> >> http://blogs.vbcity.com/DmytroL
> >>
> >> "Angelina" <me.angel***@yahoo.com> wrote in message
> >> news:udDkEFVsGHA.4420@TK2MSFTNGP04.phx.gbl...
> >>> Is there anything similar to "Error" event of System.Web.UI.Page of
> >>> Webforms in a Windows Forms?? I want to catch all errors occured in a
> >>> windows form? I already know there is Application.ThreadException but
> >>> that is on application level.
> >>>
> >>> - angi
> >>>
> >>
> >
> >

AddThis Social Bookmark Button