Hi all,

I am trying to catch the exceptions from a VB.NET app.

I use a startup project, so that i can show the MDI main application window
as a dialog within a Try Catch block. se below..

Try

Dim f as MainForm
f.ShowDialog()

Catch ex as Exception
' write nice error reporting routine!
End Try

Then in the Catch ex as Exception.. I write a nice error file..

This all works fine when i run the App from within the IDE, but when i run
outside of the IDE i.e. run the .exe file. it doesn't seem to catch the
exception???

It brings up a dialog box, with the error details, and allows the user to
hit the continue button and carry on as if nothing happened!?

Anyone else had this problem? or am i just doing something wrong?

Thanks in Advance.
R.

Re: Exceptions, not being caught outside of the IDE!!! by hirf-spam-me-here

hirf-spam-me-here
Wed Jun 30 07:37:05 CDT 2004

* "Rigga" <s@v.c> scripsit:
> I use a startup project, so that i can show the MDI main application window
> as a dialog within a Try Catch block. se below..
>
> Try
>
> Dim f as MainForm
> f.ShowDialog()
>
> Catch ex as Exception
> ' write nice error reporting routine!
> End Try
>
> Then in the Catch ex as Exception.. I write a nice error file..
>
> This all works fine when i run the App from within the IDE, but when i run
> outside of the IDE i.e. run the .exe file. it doesn't seem to catch the
> exception???
>
> It brings up a dialog box, with the error details, and allows the user to
> hit the continue button and carry on as if nothing happened!?

Add a handler to 'Application.ThreadException'...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Re: Exceptions, not being caught outside of the IDE!!! by Cor

Cor
Wed Jun 30 08:10:45 CDT 2004

Hi Rigga,

In what situation are you able to get an exeption in this routine?
Try
Dim f as MainForm
f.ShowDialog()
Catch ex as Exception
' write nice error reporting routine!
End Try

Or is mainform the class itself and is it a kind of endless loop?

Cor



Re: Exceptions, not being caught outside of the IDE!!! by Rigga

Rigga
Wed Jun 30 08:19:40 CDT 2004

Hi Herfried,

Thanks, that's got around the problem. You're a star.!!

R.

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:2kfquvF1t1gkU1@uni-berlin.de...
> * "Rigga" <s@v.c> scripsit:
> > I use a startup project, so that i can show the MDI main application
window
> > as a dialog within a Try Catch block. se below..
> >
> > Try
> >
> > Dim f as MainForm
> > f.ShowDialog()
> >
> > Catch ex as Exception
> > ' write nice error reporting routine!
> > End Try
> >
> > Then in the Catch ex as Exception.. I write a nice error file..
> >
> > This all works fine when i run the App from within the IDE, but when i
run
> > outside of the IDE i.e. run the .exe file. it doesn't seem to catch the
> > exception???
> >
> > It brings up a dialog box, with the error details, and allows the user
to
> > hit the continue button and carry on as if nothing happened!?
>
> Add a handler to 'Application.ThreadException'...
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>



Re: Exceptions, not being caught outside of the IDE!!! by Rigga

Rigga
Wed Jun 30 08:20:45 CDT 2004

Hi Cor,

The mainform, is an MDI form that controls the application.

It uses showdialog for the purposes of catching the exceptions from anywhere
within the MDI form, or other forms contained within it. the actually app
contains more than 100 different forms. all running within the MDI. if
selected of course!

And as Herfried has provided a solution to the exception catching, it all
works perfectly.

R.

"Cor Ligthert" <notfirstname@planet.nl> wrote in message
news:ucZtUPqXEHA.2664@TK2MSFTNGP09.phx.gbl...
> Hi Rigga,
>
> In what situation are you able to get an exeption in this routine?
> Try
> Dim f as MainForm
> f.ShowDialog()
> Catch ex as Exception
> ' write nice error reporting routine!
> End Try
>
> Or is mainform the class itself and is it a kind of endless loop?
>
> Cor
>
>



Re: Exceptions, not being caught outside of the IDE!!! by Rigga

Rigga
Wed Jun 30 08:44:32 CDT 2004

Thanks David.

"David Williams" <DavidWilliams@discussions.microsoft.com> wrote in message
news:AE3A294E-AF89-4FD9-8594-8189CCA33F35@microsoft.com...
> Assuming that the code that you showed is in a module, and the subroutine
is the startup routine, then you need to add handlers for two different
events in this module, Threading.ThreadAbortException and
System.UnhandledException.
>
> ThreadAbortExceptionHandler will handle non-controlled shutdown of the
application while the UnhandledExceptionHandler will catch all other
exceptions that caused the application to crash.
>
> I normally just tell the user and log (to the EventLog) the
ThreadAbortException while in the UnhandledExceptionHandler gets the
full-blown exception reporting handling.
>
> HTH
> --
> David Williams, VB.NET MVP
>
>
> "Rigga" wrote:
>
> > Hi all,
> >
> > I am trying to catch the exceptions from a VB.NET app.
> >
> > I use a startup project, so that i can show the MDI main application
window
> > as a dialog within a Try Catch block. se below..
> >
> > Try
> >
> > Dim f as MainForm
> > f.ShowDialog()
> >
> > Catch ex as Exception
> > ' write nice error reporting routine!
> > End Try
> >
> > Then in the Catch ex as Exception.. I write a nice error file..
> >
> > This all works fine when i run the App from within the IDE, but when i
run
> > outside of the IDE i.e. run the .exe file. it doesn't seem to catch the
> > exception???
> >
> > It brings up a dialog box, with the error details, and allows the user
to
> > hit the continue button and carry on as if nothing happened!?
> >
> > Anyone else had this problem? or am i just doing something wrong?
> >
> > Thanks in Advance.
> > R.
> >
> >
> >



Re: Exceptions, not being caught outside of the IDE!!! by Jay

Jay
Wed Jun 30 10:45:46 CDT 2004

Rigga,
You should not use ShowDialog to show your MDI form, use Application.Run
along with the 'Application.ThreadException' that Herfried & I pointed out.
The article I mention in my other post also includes the events that David
is referring to.

Hope this helps
Jay

"Rigga" <s@v.c> wrote in message
news:f6zEc.976$Fc7.225524@stones.force9.net...
> Hi Cor,
>
> The mainform, is an MDI form that controls the application.
>
> It uses showdialog for the purposes of catching the exceptions from
anywhere
> within the MDI form, or other forms contained within it. the actually app
> contains more than 100 different forms. all running within the MDI. if
> selected of course!
>
> And as Herfried has provided a solution to the exception catching, it all
> works perfectly.
>
> R.
>
> "Cor Ligthert" <notfirstname@planet.nl> wrote in message
> news:ucZtUPqXEHA.2664@TK2MSFTNGP09.phx.gbl...
> > Hi Rigga,
> >
> > In what situation are you able to get an exeption in this routine?
> > Try
> > Dim f as MainForm
> > f.ShowDialog()
> > Catch ex as Exception
> > ' write nice error reporting routine!
> > End Try
> >
> > Or is mainform the class itself and is it a kind of endless loop?
> >
> > Cor
> >
> >
>
>



Re: Exceptions, not being caught outside of the IDE!!! by Jay

Jay
Wed Jun 30 10:45:56 CDT 2004

Rigga,
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.

It can be beneficial to combine the above global handlers in your app, as
well as wrap your Sub Main in a try catch itself.

There is an article in the June 2004 MSDN Magazine that shows how to
implement the global exception handling in .NET that explains why & when you
use multiple of the above handlers...

http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx

For example: In my Windows Forms apps I would have a handler attached to the
Application.ThreadException event, plus a Try/Catch in my Main. The
Try/Catch in Main only catches exceptions if the constructor of the MainForm
raises an exception, the Application.ThreadException handler will catch all
uncaught exceptions from any form/control event handlers.

Hope this helps
Jay


"Rigga" <s@v.c> wrote in message
news:JnwEc.950$Fc7.219775@stones.force9.net...
> Hi all,
>
> I am trying to catch the exceptions from a VB.NET app.
>
> I use a startup project, so that i can show the MDI main application
window
> as a dialog within a Try Catch block. se below..
>
> Try
>
> Dim f as MainForm
> f.ShowDialog()
>
> Catch ex as Exception
> ' write nice error reporting routine!
> End Try
>
> Then in the Catch ex as Exception.. I write a nice error file..
>
> This all works fine when i run the App from within the IDE, but when i run
> outside of the IDE i.e. run the .exe file. it doesn't seem to catch the
> exception???
>
> It brings up a dialog box, with the error details, and allows the user to
> hit the continue button and carry on as if nothing happened!?
>
> Anyone else had this problem? or am i just doing something wrong?
>
> Thanks in Advance.
> R.
>
>



Re: Exceptions, not being caught outside of the IDE!!! by Rigga

Rigga
Thu Jul 01 04:47:48 CDT 2004

Hi Jay,

Thanks for both your posts, I think a change to the way the App start's is
required.

Again, thanks for your input. Much appreciated.

R.

"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:uhwvolrXEHA.1000@TK2MSFTNGP12.phx.gbl...
> Rigga,
> 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.
>
> It can be beneficial to combine the above global handlers in your app, as
> well as wrap your Sub Main in a try catch itself.
>
> There is an article in the June 2004 MSDN Magazine that shows how to
> implement the global exception handling in .NET that explains why & when
you
> use multiple of the above handlers...
>
> http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx
>
> For example: In my Windows Forms apps I would have a handler attached to
the
> Application.ThreadException event, plus a Try/Catch in my Main. The
> Try/Catch in Main only catches exceptions if the constructor of the
MainForm
> raises an exception, the Application.ThreadException handler will catch
all
> uncaught exceptions from any form/control event handlers.
>
> Hope this helps
> Jay
>
>
> "Rigga" <s@v.c> wrote in message
> news:JnwEc.950$Fc7.219775@stones.force9.net...
> > Hi all,
> >
> > I am trying to catch the exceptions from a VB.NET app.
> >
> > I use a startup project, so that i can show the MDI main application
> window
> > as a dialog within a Try Catch block. se below..
> >
> > Try
> >
> > Dim f as MainForm
> > f.ShowDialog()
> >
> > Catch ex as Exception
> > ' write nice error reporting routine!
> > End Try
> >
> > Then in the Catch ex as Exception.. I write a nice error file..
> >
> > This all works fine when i run the App from within the IDE, but when i
run
> > outside of the IDE i.e. run the .exe file. it doesn't seem to catch the
> > exception???
> >
> > It brings up a dialog box, with the error details, and allows the user
to
> > hit the continue button and carry on as if nothing happened!?
> >
> > Anyone else had this problem? or am i just doing something wrong?
> >
> > Thanks in Advance.
> > R.
> >
> >
>
>