PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Override default exception dialog
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Override default exception dialog
![]() |
Override default exception dialog |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Just wondering, is there a way to disable or override the default .NET
exception dialog with your own for an entire application? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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? > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

