unhandled exception of type 'System.StackOverflowException'


  • Hi,
    I've got an exception -  

    An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll

     from the following codes


    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports System.Data
    Imports System.IO
    Imports System.Drawing
    Imports System.Windows.Forms

    Public Class Form1
        Dim lb_user_id As Label
        Dim tb_user_id As TextBox
        Dim form1 As New Form1()
        Dim WithEvents bt_exit As System.Windows.Forms.Button

        Public Sub New()

            ' This call is required by the Windows Form Designer.

            ' Add any initialization after the InitializeComponent() call.
            tb_user_id = New System.Windows.Forms.TextBox()
            bt_exit = New System.Windows.Forms.Button()

            tb_user_id.Location = New System.Drawing.Point(130, 12)
            tb_user_id.Name = "tb_user_id"
            tb_user_id.Size = New System.Drawing.Size(100, 20)
            tb_user_id.TabIndex = 29
            tb_user_id.Enabled = False
            ' bt_exit
            bt_exit.Location = New System.Drawing.Point(625, 460)
            bt_exit.Name = "bt_exit"
            bt_exit.Size = New System.Drawing.Size(80, 25)
            bt_exit.TabIndex = 69
            bt_exit.Text = "E&xit"
            'bt_exit.Click += New System.EventHandler(bt_exit_Clicked)
            ' Form1
            form1.ClientSize = New System.Drawing.Size(760, 500)
            form1.Location = New System.Drawing.Point(600, 30)
            form1.Name = "Form1"

        End Sub
        Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        End Sub

        Protected Sub bt_exit_Clicked(ByVal sender As Object, ByVal e As EventArgs) Handles bt_exit.Click
            form1.DialogResult = DialogResult.Cancel
        End Sub

    End Class


    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class Form1
        Inherits System.Windows.Forms.Form

        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
                If disposing AndAlso components IsNot Nothing Then
                End If
            End Try
        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.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            components = New System.ComponentModel.Container()
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.Text = "Form1"
        End Sub

    End Class

    Any advice? Is there an example which is working fine?
    Thanks & Best Regards, HuaMin Chen. In Hong Kong, China.
    vendredi 16 janvier 2009 11:17


  • Remove the 'Dim form1 As New Form1()'  That should resolve your issue.

    Public Sub Main()
    End Sub

    Private Sub Rant(ByVal thisRant as Boolean)

    Select Case thisRant
         Case True
    For any newbs......... Please............. learn how to use the debugger.  Learn how to set breakpoints, and step through your code, line by line.  The skills developed in that process will prove to be more valuable than posting some ambiguous question and waiting for a response.  
    For a quick guide on how to use the debugger, please see ReneeC's thread about it.  
    Please dont hesitate to ask any further questions you may have, no matter how silly you may think they are, however I implore you to learn to use the debugger!    
    Seriously........... NO ONE, writes a program without using the the various debugging options available.   IT IS IMPOSSIBLE!  LEARN IT!  USE IT!  LIVE IT!  ;)  
    End Select          

    End Sub

    Sidebar:  The term newbs is NOT derogatory, it is simply what it is.  We all understand its meaning, and accepts its definition.  Everyone, but the elite, are newbs at some level or another.  Do not take offense, but take it as a challenge, dont be a newb.  Software engineering is a CONSTANT NEVER ENDING CHALLENGE to learn something new.  Whether it be past, current, or future technologies, your uphill climb will NEVER stop.  That is the beauty of engineering.  You can see the mountain peek, but you will never reach it.  Its those that keep trying that will succeed.

    Compensating what I don't know yet, with what I do know now.
    vendredi 16 janvier 2009 11:50