找不到为什么抛出 'NullReference Exception'

Can not find out why 'NullReference Exception' is thorwn

我的 Windows 表单应用程序中有一个 Telerik Tabbed PageView,我可以通过双击启动文本编辑器来编辑选项卡的标题。以下订阅者正在处理更改后的标签 - 检查编辑后的标签是否为空:

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

此外,我的 Form_Load 事件中有这条线:

AddHandler MountingSystemTabControl.ViewElement.EditorInitialized, AddressOf ViewElement_EditorInitialized

现在的问题是,每当我 运行 代码时,MessageBox 都会显示“数组标签已成功更新!”消息,一个 NullReference Exception 被抛出,似乎即使使用应用程序事件处理程序我也无法捕获它!破解代码后,Visual Studio 将此行作为异常源:

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

这就是让我感到困惑的原因,因为我找不到该行中引用的任何内容(当然有,但我不知道是什么)。

Call Stack screenshot

Main idea of the code.

记忆犹新...我认为 RadMessageBox 需要 Parent 参数。

试试这个:

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

问题已通过更新至 'Telerik UI for WinForms Q1 2015 (version 2015.1.225)'

得到解决