dimanche 15 mars 2015

Can not find out why 'NullReference Exception' is thorwn

I have a Telerik Tabbed PageView in my Windows Form application which I can edit tab's titles by double clicking on them which initiates a text editor. Following subs are taking care of altered labels - check the edited labels not to be blank:



Private Sub ViewElement_EditorInitialized(sender As Object, e As UI.RadPageViewEditorEventArgs)
AddHandler MountingSystemTabControl.ViewElement.ActiveEditor.Validating, AddressOf ActiveEditor_Validating
AddHandler MountingSystemTabControl.ViewElement.ActiveEditor.Validated, AddressOf ActiveEditor_Validated
AddHandler MountingSystemTabControl.ViewElement.ActiveEditor.ValidationError, AddressOf ActiveEditor_ValidationError
End Sub

Private Sub ActiveEditor_Validating(sender As Object, e As CancelEventArgs)
Dim editor As UI.RadPageViewElement.PageViewItemTextEditor = TryCast(sender, UI.RadPageViewElement.PageViewItemTextEditor)
If editor IsNot Nothing AndAlso MountingSystemTabControl.ViewElement.ActiveEditor.Value = String.Empty Then
e.Cancel = True
End If
End Sub

Private Sub ActiveEditor_ValidationError(sender As Object, e As UI.ValidationErrorEventArgs)
RadMessageBox.Show("Array label can't be empty!", "Error", MessageBoxButtons.OK, RadMessageIcon.[Error])
End Sub

Private Sub ActiveEditor_Validated(sender As Object, e As EventArgs)
RadMessageBox.Show("Array label has been successfully updated!", "Information", MessageBoxButtons.OK, RadMessageIcon.Info)
End Sub


Moreover, this line is there in my Form_Load event:



AddHandler MountingSystemTabControl.ViewElement.EditorInitialized, AddressOf ViewElement_EditorInitialized


Now the problem is, whenever I run the code, after the MessageBox shows me the "Array label has been successfully updated!" message, a NullReference Exception is thrown which it seems I can't catch it not even with Application Event handlers ! After breaking the code, Visual Studio refers me to this line as the source of the exception:



RadMessageBox.Show("Array label has been successfully updated!", "Information", MessageBoxButtons.OK, RadMessageIcon.Info)


And that's what confuses me because I can't find anything referenced in that line (of course there is something but I don't know what).


Call Stack screenshot


Main idea of the code.


Aucun commentaire:

Enregistrer un commentaire