Exception firing at design time - how to avoid?

  • Thread starter Thread starter Jack Addington
  • Start date Start date
J

Jack Addington

1) I have created a visual control that relies on a logic class to do much
of its work.
2) The logic class will be assigned on the form through a register method.
3) I have a public property for accessing the control defined.
4) To avoid other people calling the control before it is initialized I
throw an ArgumentNullException in the propert.get section.

My problem is that when I place this visual control on a form, the exception
is firing. How do I get this exception to only fire at runtime or do I need
to re-arrange my code/thinking?

public LogicObj Logic
{
get
{
if ( _logic == null ) throw new ArgumentNullException(...);
return _logic;
}
}

thx

jack
 
Jack Addington said:
1) I have created a visual control that relies on a logic class to do much
of its work.
2) The logic class will be assigned on the form through a register method.
3) I have a public property for accessing the control defined.
4) To avoid other people calling the control before it is initialized I
throw an ArgumentNullException in the propert.get section.

My problem is that when I place this visual control on a form, the
exception is firing. How do I get this exception to only fire at runtime
or do I need to re-arrange my code/thinking?

Look at the DesignMode property. It's true when you're in a designer.

if (!DesignMode)...
 
Back
Top