Exception causes load event to end

  • Thread starter Thread starter Stickybit
  • Start date Start date
S

Stickybit

Hi guys and gals

I'm having a wierd problem with my application. I'm calling a few functions
and subs from my main load event, and everything works just fine - except
when one of functions throws an exception (which is handled by the function
itself).

When an exception has ocured (and been handled) in one of the functions, and
the rest of the code, in the main load event should run - northing happens.
It's like the rest of the load event just had been completely forgotten.

What could be the problem here?

Regards Søren Schimkat
 
Hi,

If not done, a first step could be to throw a dummy exception and step into
your code to see what is the code flow...

If you don't see what happens seeing some code (we just need 10 lines of
code that would repro the problem, not your whole code) and knowing which
exception you get could help to diagnose the problem.

During this step it is likely you'll find the problem or you'll have
something simple to show.
 
Stickybit said:
Hi guys and gals

I'm having a wierd problem with my application. I'm calling a few functions
and subs from my main load event, and everything works just fine - except
when one of functions throws an exception (which is handled by the function
itself).

When an exception has ocured (and been handled) in one of the functions, and
the rest of the code, in the main load event should run - northing happens.
It's like the rest of the load event just had been completely forgotten.

What could be the problem here?

Regards Søren Schimkat

Can you provide a small example that fails? If I understand your point, the
code below should not set the label to "Success!!", but it does. So this
code is not doing the same as yours.

Public Class Form1

Sub ExceptionalRoutine()
Throw New Exception("Whoopee!")
End Sub

Sub YogiBerra()
Try
ExceptionalRoutine()
Catch ex as Exception
MessageBox.Show("Caught exception...")
End Try
End Sub

Private Sub Form1_Load _
(ByVal sender as Object, ByVal e as System.EventArgs) _
Handles Me.Load

YogiBerra()
Label1.Text = "Success!"
End Sub
End Class
 
Back
Top