System.StackOverflow error

1

I am working on a update to an existing Windows Store App written in VB.net. I made a shared MsgBox() function and a "un-shared" one (which is to be run from the shared one). I need the shared one because I also run it from another class. The full error code:

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)

Here is the MsgBox code:

''' <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
windows
vb.net
microsoft-metro
asked on Stack Overflow Nov 25, 2012 by MDTech.us_MAN • edited Mar 20, 2013 by Shadow The Vaccinated Wizard

1 Answer

4

Your MsgBox function calls itself - resulting in infinite recursion and therefore stack overflow. You probably meant MsgBox to call MsgBox_unShared.

answered on Stack Overflow Nov 25, 2012 by Igor • edited Nov 25, 2012 by Igor

User contributions licensed under CC BY-SA 3.0