以下屏幕截图中显示的错误偶尔会发生:
应用程序本身在非托管 C++ 中,使用 COM 对象和通过 COM 互操作的 .NET 对象(在 C# 和 VB 中)。
我们的代码中只有堆栈跟踪中的两个函数
McWrapperControl.ControlHost.InvokeMethod
Public Sub InvokeMethod(ByVal Member As String, ByVal NumArgs As Integer, ByVal Args As Object)
Try
Dim ArgsType As Type = Args.GetType()
Dim ArgsArray As Object
If NumArgs = 0 Then
ArgsArray = Nothing
ElseIf ArgsType.IsArray Then
ArgsArray = Args
Else
ArgsArray = {Args}
End If
InvokeMethod_ArgsArray(Member, ArgsArray)
Catch ex As Exception
ReportError.ShowErrorDialog(ex, "")
End Try
End Sub
和McWrapperControl.ControlHost.InvokeMethod_ArgsArray
Public Sub InvokeMethod_ArgsArray(ByVal Member As String, ByVal ArgsArray As Object)
Try
Dim Target As Object = ContainedControl()
If Target IsNot Nothing Then
Dim TargetType As Type = Target.GetType()
TargetType.InvokeMember(Member, BindingFlags.InvokeMethod, Nothing, Target, ArgsArray)
End If
Catch ex As MissingMethodException
'Ignore this error
Catch ex As Exception
ReportError.ShowErrorDialog(ex, "")
End Try
End Sub
在这种情况下,我相当肯定正在发生 MissingMethodException,但这应该被捕获并忽略。显然,在尝试调用它之前,我可以通过检查命名方法的存在来防止这个错误。
除此之外,任何人都可以解释可能导致这种递归的原因吗?