System.StackOverflow错误

时间:2012-11-25 14:24:58

标签: windows vb.net microsoft-metro

我正在研究用VB.net编写的现有Windows应用商店应用的更新。 我创建了一个共享的MsgBox()函数和一个“un-shared”函数(它将从共享函数运行)。我需要共享的,因为我也从另一个类运行它。完整的错误代码:

An unhandled exception of type 'System.StackOverflowException' occurred in Calculator World.exe
The program '[4360] Calculator World.exe: Managed (v4.0.30319)' has exited with code -2147023895 (0x800703e9)

这是MsgBox代码:

''' <summary>
''' Shows a message box with a Close button.
''' 
''' NOTE: Run "MainPage.MessageBoxDone = false" before running this function!!!
''' </summary>
''' <param name="text">The text to show in the message box.</param>
Public Shared Sub MsgBox(ByVal text As String)'<--- error is occurring  ether here 
    MsgBox(text)                          ' <--- or here
End Sub

Private Sub MsgBox_unShared(ByVal txt As String)
    Canvas_MsgBox.Visibility = Windows.UI.Xaml.Visibility.Visible
    Label_MsgBox.Text = txt
End Sub

1 个答案:

答案 0 :(得分:4)

您的MsgBox函数调用自身 - 导致无限递归,因此堆栈溢出。您可能需要MsgBox来致电MsgBox_unShared