PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Override default exception dialog

Reply

Override default exception dialog

 
Thread Tools Rate Thread
Old 24-06-2003, 06:03 PM   #1
Dacris Software
Guest
 
Posts: n/a
Default Override default exception dialog


Just wondering, is there a way to disable or override the default .NET
exception dialog with your own for an entire application?


  Reply With Quote
Old 25-06-2003, 01:01 AM   #2
Herfried K. Wagner
Guest
 
Posts: n/a
Default Re: Override default exception dialog

Hello,

"Dacris Software" <contact@dacris.com> schrieb:
> Just wondering, is there a way to disable or override the default .NET
> exception dialog with your own for an entire application?


Try this:

\\\
Public Class Main
Public Sub Main()
Try
Application.Run(New MainForm())
Catch ex As Exception
...
End Try
End Sub
End Class
///

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


  Reply With Quote
Old 25-06-2003, 01:50 AM   #3
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Override default exception dialog

Dacris,
Wrapping your Application.Run method with a Try/Catch block will not catch
unhandled exceptions.

The events occur asynchronously, in response to mouse clicks & other user or
system actions, if you were to catch these after Application.Run your app
would have stopped running (Application.Run is a 'Message Pump' loop, you
do not want that loop to exit, unless you are exiting your app).

If you want to avoid the window that says there was an unhandled exception,
you can use global exception handlers in your .NET app.

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.

Something like:

Public Sub Main()
AddHandler Application.ThreadException, AddressOf OnThreadException
Application.Run(New MainForm)
End Sub

Private Sub OnThreadException(sender As Object, _
ByVal e As System.Threading.ThreadExceptionEventArgs)
Try
' Show your own form
Catch ex As Exception
' Don't want to end the app here! ;-)
End Try
End Sub

Hope this helps
Jay


"Dacris Software" <contact@dacris.com> wrote in message
news:OLRnyrnODHA.1748@TK2MSFTNGP11.phx.gbl...
> Just wondering, is there a way to disable or override the default .NET
> exception dialog with your own for an entire application?
>
>



  Reply With Quote
Old 25-06-2003, 11:01 AM   #4
Herfried K. Wagner
Guest
 
Posts: n/a
Default Re: Override default exception dialog

Hello,

"Herfried K. Wagner" <hirf.nosp@m.activevb.de> schrieb:
> > Just wondering, is there a way to disable or override the default

..NET
> > exception dialog with your own for an entire application?


Ooops. That's better:

http://msdn.microsoft.com/library/e...eptiontopic.asp

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off