O
Oblivion
Hi All,
I have an issue where I get an "Unhandled Exception" pop up box when
an error occurs in an inherited base class even tho there's a
try..catch written in the inheriting class to handle it. I've got an
example of the code below to give you an idea of what's occuring. I
thought the try..catch took care of everything... do I HAVE to write
the try..catch logic in the base class? Is this a quirk with class
inheritence or .NET?
Thanks in advance for all replies!
******************************************************************************************************
Code:
public class BaseClass
{
private int myProperty=0;
public int MyProperty
{
get {return myProperty;}
set {myProperty = value; if (myProperty > 1) {timer1.start()}
else {timer1.stop()}
}
private timer1_tick(object sender, eventargs e)
{
DoSomething(); // EXCEPTION OCCURS HERE!!
}
}
public class InheritedClass : BaseClass
{
public InheritedClass()
{
// CONSTRUCTOR...
}
public void UseBase()
{
try
{
this.MyProperty = 5; // This should kick off the
timer....
}
catch (Exception e)
{
WriteError(e.Message);
}
}
}
I have an issue where I get an "Unhandled Exception" pop up box when
an error occurs in an inherited base class even tho there's a
try..catch written in the inheriting class to handle it. I've got an
example of the code below to give you an idea of what's occuring. I
thought the try..catch took care of everything... do I HAVE to write
the try..catch logic in the base class? Is this a quirk with class
inheritence or .NET?
Thanks in advance for all replies!
******************************************************************************************************
Code:
public class BaseClass
{
private int myProperty=0;
public int MyProperty
{
get {return myProperty;}
set {myProperty = value; if (myProperty > 1) {timer1.start()}
else {timer1.stop()}
}
private timer1_tick(object sender, eventargs e)
{
DoSomething(); // EXCEPTION OCCURS HERE!!
}
}
public class InheritedClass : BaseClass
{
public InheritedClass()
{
// CONSTRUCTOR...
}
public void UseBase()
{
try
{
this.MyProperty = 5; // This should kick off the
timer....
}
catch (Exception e)
{
WriteError(e.Message);
}
}
}