none
An unhandled exception of type 'System.StackOverflowException' occurred

    Question

  • Hello,

    I am working on a multi-form code.  For some reason, this randomly began happening just about the time I finished my code. The intial form loads just fine, but when I go to click on any of the selected buttons, the code crashes. and I get an unhandled exception of type 'System.stackoverflowexception' occured. Does anyone have any ideas? I have checked for any subs calling subs that call subs and I don't have anything of that nature.  It is breaking at the point that is bolded and underlined.

    Public Class Add_Description
    Inherits System.Windows.Forms.Form



    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New( )

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents TxtTime As System.Windows.Forms.TextBox
    Friend WithEvents TxtDescription As System.Windows.Forms.TextBox
    Friend WithEvents BtnSave As System.Windows.Forms.Button
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label
    Me.TxtTime = New System.Windows.Forms.TextBox
    Me.TxtDescription = New System.Windows.Forms.TextBox
    Me.BtnSave = New System.Windows.Forms.Button
    Me.MainMenu1 = New System.Windows.Forms.MainMenu
    Me.MenuItem1 = New System.Windows.Forms.MenuItem
    Me.MenuItem2 = New System.Windows.Forms.MenuItem
    Me.MenuItem3 = New System.Windows.Forms.MenuItem
    Me.MenuItem4 = New System.Windows.Forms.MenuItem
    Me.MenuItem5 = New System.Windows.Forms.MenuItem
    Me.MenuItem6 = New System.Windows.Forms.MenuItem
    Me.MenuItem7 = New System.Windows.Forms.MenuItem
    Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
    Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.Location = New System.Drawing.Point(64, 8)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(248, 24)
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Description Information"
    Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'TxtTime
    '
    Me.TxtTime.Location = New System.Drawing.Point(24, 48)
    Me.TxtTime.Name = "TxtTime"
    Me.TxtTime.Size = New System.Drawing.Size(72, 20)
    Me.TxtTime.TabIndex = 1
    Me.TxtTime.Text = ""
    '
    'TxtDescription
    '
    Me.TxtDescription.Location = New System.Drawing.Point(104, 48)
    Me.TxtDescription.Name = "TxtDescription"
    Me.TxtDescription.Size = New System.Drawing.Size(280, 20)
    Me.TxtDescription.TabIndex = 2
    Me.TxtDescription.Text = ""
    '
    'BtnSave
    '
    Me.BtnSave.Location = New System.Drawing.Point(168, 72)
    Me.BtnSave.Name = "BtnSave"
    Me.BtnSave.Size = New System.Drawing.Size(56, 24)
    Me.BtnSave.TabIndex = 3
    Me.BtnSave.Text = "Save"
    '
    'MainMenu1
    '
    Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem7})
    '
    'MenuItem1
    '
    Me.MenuItem1.Index = 0
    Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2, Me.MenuItem3, Me.MenuItem4, Me.MenuItem5, Me.MenuItem6})
    Me.MenuItem1.Text = "&File"
    '
    'MenuItem2
    '
    Me.MenuItem2.Index = 0
    Me.MenuItem2.Text = "&Open"
    '
    'MenuItem3
    '
    Me.MenuItem3.Index = 1
    Me.MenuItem3.Text = "&Save"
    '
    'MenuItem4
    '
    Me.MenuItem4.Index = 2
    Me.MenuItem4.Text = "Save &As"
    '
    'MenuItem5
    '
    Me.MenuItem5.Index = 3
    Me.MenuItem5.Text = "-"
    '
    'MenuItem6
    '
    Me.MenuItem6.Index = 4
    Me.MenuItem6.Text = "E&xit"
    '
    'MenuItem7
    '
    Me.MenuItem7.Index = 1
    Me.MenuItem7.Text = "A&bout"
    '
    'Add_Description
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(392, 106)
    Me.Controls.Add(Me.BtnSave)
    Me.Controls.Add(Me.TxtDescription)
    Me.Controls.Add(Me.TxtTime)
    Me.Controls.Add(Me.Label1)
    Me.Menu = Me.MainMenu1
    Me.Name = "Add_Description"
    Me.Text = "Add_Description"
    Me.ResumeLayout(False)

    End Sub

    #End Region
    'Dim Class Variables
    Dim Time As String
    Dim Description As String
    Dim Document As String = ""
    'Dim Form Name variables
    Dim AddDescription As New Add_Description
    Dim Form1 As New Form1
    Dim InformationUpdate As New Information_Update
    Dim AddOperator As New Information_Update

    'Documentname holds the document file name
    Dim Documentname As String = ("")
    'IsChanged hold true when the document has been changed since it was last saved.
    'It holds false when the document has not been changed since it was last saved.
    Dim ischanged As Boolean = False
    Private Sub TxtTime_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtTime.TextChanged
    'Update the isChanged variable to indicate that the text has changed
    ischanged = True
    End Sub

    Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click

    End Sub

    Private Sub Add_Description_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub TxtDescription_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtDescription.TextChanged
    'Update the isChanged variable to indicate that the text has changed
    ischanged = True
    End Sub

    Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem7.Click
    MessageBox.Show("This program was written by Bowers Computer Repair. Copywrite 2009", "About", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub
    Sub Opendocument()
    'Use the OpenFileDialog control to get a file name
    Dim ARESlog As System.IO.StreamReader

    If OpenFileDialog1.ShowDialog = DialogResult.OK Then
    Documentname = OpenFileDialog1.FileName
    ARESlog = System.IO.File.OpenText(Documentname)
    MessageBox.Show("I'm Sorry, the document can not be opened on this form.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Error)

    Else
    MessageBox.Show(Documentname & " does not exist", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
    End If


    End Sub
    Sub ClearDocument()
    'Clears the contents of the text boxes
    TxtTime.Clear()
    TxtDescription.Clear()
    Documentname = ""

    End Sub
    Sub SaveDocument()
    'Save the current document under then name stored in documentname.
    Dim ARESlog As System.IO.StreamWriter
    ARESlog = System.IO.File.CreateText(Documentname)

    'Defines and carries textbox strings over to variables


    Time = TxtTime.Text
    Description = TxtDescription.Text

    'Writes Items to file

    ARESlog.WriteLine(Time)
    ARESlog.WriteLine(Description)


    End Sub
    Sub saveas()
    If SaveFileDialog1.ShowDialog = DialogResult.OK Then
    Documentname = SaveFileDialog1.FileName
    SaveDocument()
    End If
    End Sub
    End Class
    • Moved by Harry Zhu Wednesday, July 15, 2009 2:38 AM relating to vb.net (From:Visual C# Language)
    Monday, July 13, 2009 2:24 AM

All replies

  • Hard to tell, source looks like a complete mess, incomplete  and on top of that its VB (you posted in the C# forum) Take a look at the stack on the moment the stack overflow occurs you are probably recursivly calling the same functions over and over agin.
    Monday, July 13, 2009 6:47 AM