S
Steve W
We are hitting a problem that we can't explain and wondered if anyone has
seen this before or can suggest how we can stop it happening :
Form 'A' inherits from System.Windows.Forms.Form
Form 'B' inherits from Form 'A'.
Form C inherits from Form B.
Form B (the one in the middle) has a TextBox component on it.
The constructor of Form 'C' attempts to assign a string value to the 'Text'
property of the TextBox. It does this after all form initialization has
taken place.
Occasionally (we haven't identified a definite pattern), when the code
assigning the 'Text' property of the TextBox executes, it falls over with an
exception 'Object variable not set to an instance of an object'.
The problem definitely lies with the assignment (i.e. does not lie with the
value being assigned). We've also tried Me.TextBox.Text = value and
MyBase.TextBox.Text = value but still the same. We've also tried assigning
values to different components (such as CheckBox.Checked = True) and the
same thing happens. The component can be read; i.e. code like
MsgBox(TextBox.Text) works fine.
We thought we had solved the problem when discovering that if the component'
s properties have anything assigned to them at design time, then this
run-time issue would occur fairly frequently (but seemingly randomly).
Ensuring nothing is assigned at design time (i.e. the 'Text' property or
'Checked' property is not assigned at design time) seemed to halt the issue
occurring. However, now it is occurring again and we can't fix it.
This does seem to be a form inheritance issue as I haven't seen it on any
forms that are just inherited from System.Windows.Forms.Form.
Thanks for any help,
Steve
seen this before or can suggest how we can stop it happening :
Form 'A' inherits from System.Windows.Forms.Form
Form 'B' inherits from Form 'A'.
Form C inherits from Form B.
Form B (the one in the middle) has a TextBox component on it.
The constructor of Form 'C' attempts to assign a string value to the 'Text'
property of the TextBox. It does this after all form initialization has
taken place.
Occasionally (we haven't identified a definite pattern), when the code
assigning the 'Text' property of the TextBox executes, it falls over with an
exception 'Object variable not set to an instance of an object'.
The problem definitely lies with the assignment (i.e. does not lie with the
value being assigned). We've also tried Me.TextBox.Text = value and
MyBase.TextBox.Text = value but still the same. We've also tried assigning
values to different components (such as CheckBox.Checked = True) and the
same thing happens. The component can be read; i.e. code like
MsgBox(TextBox.Text) works fine.
We thought we had solved the problem when discovering that if the component'
s properties have anything assigned to them at design time, then this
run-time issue would occur fairly frequently (but seemingly randomly).
Ensuring nothing is assigned at design time (i.e. the 'Text' property or
'Checked' property is not assigned at design time) seemed to halt the issue
occurring. However, now it is occurring again and we can't fix it.
This does seem to be a form inheritance issue as I haven't seen it on any
forms that are just inherited from System.Windows.Forms.Form.
Thanks for any help,
Steve