Home All Groups Group Topic Archive Search About

Exception handling problem

Author
13 Apr 2005 2:57 PM
Donzo
I have an application that has many different parts to it.  The main
application is nothing more than a tool bar to launch the different parts of
the application (differnt forms or routines).
For one of the parts when you click a button on the toolbar, a sub routine
is run.  Here are the basics of that sub routine:
Try
            Dim frm As New frmUserHome
            frm.ShowDialog()
        Catch ex As Exception
            MessageBox.Show("Any error has occured in the PO Req system." &
Chr(10) & "An email is being sent to the developer with the specifics of the
error" & Chr(10) & "The PO Req system will shutdown now", "Application
Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            ' Code to send email with exception details
            Exit Sub
         End Try

Am I wrong in assuming that if I have no other Try..Catch blocks in my code
that if an exception occurs it will roll back up to this Try..Catch block,
display the message box I have defined and excute the email routine?
What I am seeing is that I am receiving the emails from some users and
others are sending me screen shot of the generic error message (the one with
the Details, Continue, and Quit buttons).
Why does the exception not roll up to this Try..Catch block for all users
and instead throw the .Net framework "An unhandled exception has occured"? 
My thoughts were that it kept going back until it found a Try..Catch.  If it
failed to find one, then it threw the generic "Unhandled execetion" error.
What am I missing?

Author
15 Apr 2005 1:56 AM
Patrick Steele [MVP]
In article <09353498-1AD5-4AF3-A6BC-5C9B50101***@microsoft.com>,
Do***@discussions.microsoft.com says...
Show quoteHide quote
> I have an application that has many different parts to it.  The main
> application is nothing more than a tool bar to launch the different parts of
> the application (differnt forms or routines).
> For one of the parts when you click a button on the toolbar, a sub routine
> is run.  Here are the basics of that sub routine:
> Try
>             Dim frm As New frmUserHome
>             frm.ShowDialog()
>         Catch ex As Exception
>             MessageBox.Show("Any error has occured in the PO Req system." &
> Chr(10) & "An email is being sent to the developer with the specifics of the
> error" & Chr(10) & "The PO Req system will shutdown now", "Application
> Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
>             ' Code to send email with exception details
>             Exit Sub
>          End Try
>
> Am I wrong in assuming that if I have no other Try..Catch blocks in my code
> that if an exception occurs it will roll back up to this Try..Catch block,
> display the message box I have defined and excute the email routine?
> What I am seeing is that I am receiving the emails from some users and
> others are sending me screen shot of the generic error message (the one with
> the Details, Continue, and Quit buttons).
> Why does the exception not roll up to this Try..Catch block for all users
> and instead throw the .Net framework "An unhandled exception has occured"? 
> My thoughts were that it kept going back until it found a Try..Catch.  If it
> failed to find one, then it threw the generic "Unhandled execetion" error.
> What am I missing?

Are you doing anything with multiple threads?  Or different AppDomains?

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Author
15 Apr 2005 2:23 AM
Donzo
No.
No different threads or app domains.
It works as expected on my box when I am running it in debug mode.  It even
works on my box if I run the istalled version. 
I just cannot understand why on others boxes it just throws the generic
message.
The details that are contained in the generic message point to the method
that the error occured in.  It never goes beyond that point.
Here is the general 'path' of what occurs in the app:
Main toolbar>sub routine launches another form>this form launches another
form>from this form a button that accesses a data component that should
return a value from the database.  It is here that the error occurs (I know
what causes the error and I have fixed it).  My understading is that if this
error is not handled it should:
go back to form with the button that was clicked (nothing to handle the
error here)> go back to the form that launched this form (nothing to handle
the error here)>go back to the sub routine that launched this form
(try..catch block here) this should handle the error and send the email.

Show quoteHide quote
"Patrick Steele [MVP]" wrote:

> In article <09353498-1AD5-4AF3-A6BC-5C9B50101***@microsoft.com>,
> Do***@discussions.microsoft.com says...
> > I have an application that has many different parts to it.  The main
> > application is nothing more than a tool bar to launch the different parts of
> > the application (differnt forms or routines).
> > For one of the parts when you click a button on the toolbar, a sub routine
> > is run.  Here are the basics of that sub routine:
> > Try
> >             Dim frm As New frmUserHome
> >             frm.ShowDialog()
> >         Catch ex As Exception
> >             MessageBox.Show("Any error has occured in the PO Req system." &
> > Chr(10) & "An email is being sent to the developer with the specifics of the
> > error" & Chr(10) & "The PO Req system will shutdown now", "Application
> > Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
> >             ' Code to send email with exception details
> >             Exit Sub
> >          End Try
> >
> > Am I wrong in assuming that if I have no other Try..Catch blocks in my code
> > that if an exception occurs it will roll back up to this Try..Catch block,
> > display the message box I have defined and excute the email routine?
> > What I am seeing is that I am receiving the emails from some users and
> > others are sending me screen shot of the generic error message (the one with
> > the Details, Continue, and Quit buttons).
> > Why does the exception not roll up to this Try..Catch block for all users
> > and instead throw the .Net framework "An unhandled exception has occured"? 
> > My thoughts were that it kept going back until it found a Try..Catch.  If it
> > failed to find one, then it threw the generic "Unhandled execetion" error.
> > What am I missing?
>
> Are you doing anything with multiple threads?  Or different AppDomains?
>
> --
> Patrick Steele
> Microsoft .NET MVP
> http://weblogs.asp.net/psteele
>