Home All Groups Group Topic Archive Search About

Raiseevent inside catch block

Author
5 Apr 2006 2:20 AM
RJ
Can you raise an event within a catch block in VB.NET ?( 1.1 Framework)

I am seeing some unexpected behavior in other parts of the WinForm app.  I
just wondered if it is even "legal" to do this.   TIA

Author
5 Apr 2006 3:16 AM
Carl Daniel [VC++ MVP]
RJ wrote:
> Can you raise an event within a catch block in VB.NET ?( 1.1
> Framework)
> I am seeing some unexpected behavior in other parts of the WinForm
> app.  I just wondered if it is even "legal" to do this.   TIA

It certainly ought to be legal (caveat - I haven't personally verified that
for .NET 1.1, but it would be a serious flaw for this to be
illegal/undefined).

Inside the catch block the original exception is handled (no longer exists -
unless you re-throw it).  Throwing a new exception from within the catch
should still run any associated finally block and begin a new handler search
starting in the scope that contains the try/catch.

-cd
Author
5 Apr 2006 12:29 PM
Gozirra
I have raised events within a catch block in a service and within an
asp.net app without problems.  As far as I know, its perfectly legal.
Unfortunately I have no experience doing this within a windows forms
app.  What kind of unexpected behavior are you getting?
Author
5 Apr 2006 12:29 PM
Gozirra
I have raised events within a catch block in a service and within an
asp.net app without problems.  As far as I know, its perfectly legal.
Unfortunately I have no experience doing this within a windows forms
app.  What kind of unexpected behavior are you getting?

AddThis Social Bookmark Button