Form Creation error

DOTNETROOKIE

New member
Joined
Dec 10, 2006
Messages
1
Programming Experience
Beginner
I have cconverted a VB 6 project into VB.net. When I try to run the .net project, it gives the following error.

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class MDIForm1
#Region "Windows Form Designer generated code "
<System.Diagnostics.DebuggerNonUserCode()> Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub


An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'


Please advise. Thanks
 
The error itself is saying your code in the main form, was instantiate itself in the constructor or having the member declariation that is instantiated the main form, and lead to the infinite loop.

I think is something like this

VB.NET:
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] frmTextBox[/SIZE]
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE]m_myForm[SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE]frmTextBox[SIZE=2] = [COLOR=#0000ff]new [/COLOR][/SIZE]frmTextBox
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]

May be you need to change to something like this
VB.NET:
Public[SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] frmTextBox[/SIZE]
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE]m_myForm[SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE]frmTextBox[SIZE=2] = [COLOR=#0000ff]nothing[/COLOR][/SIZE]
[COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] frmTextBox_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[/COLOR]m_myForm = [COLOR=#0000ff]new [/COLOR]frmTextBox
[SIZE=2][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]
 
Back
Top