Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Windows Form Level Exception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angelina - 27 Jul 2006 08:54 GMT
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
Dmytro Lapshyn [MVP] - 27 Jul 2006 10:06 GMT
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.

Signature

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

> 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
Angelina - 27 Jul 2006 12:57 GMT
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
:)

> Hi Angelina,
>
[quoted text clipped - 14 lines]
>>
>> - angi
Patrice - 27 Jul 2006 13:11 GMT
Try AppDomain.CurrentDomain.UnhandledException and/or
Application.ThreadException

Signature

Patrice

> Hi Dmytro,
>
[quoted text clipped - 22 lines]
>>>
>>> - angi
oscar.acostamontesde@googlemail.com - 27 Jul 2006 13:43 GMT
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:

> Try AppDomain.CurrentDomain.UnhandledException and/or
> Application.ThreadException
[quoted text clipped - 33 lines]
> >>>
> >>> - angi

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.