I have created a form for my application. Once the form was working, I
copied that form to a new form that would contain all the common elements of
all forms in my application and made the existing form inherit from the
common one. Now when I try to run my application I get the following error
when I open the form:

An exception occurred while trying to create an instance of
WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
MyAppTest.frmParentForm not found.".

The relevant code for the 2 classes is included below. Can anyone tell me
what I am doing wrong here. As far as I can tell, I have the constructor
for both defined.

TIA
Ron L


frmParentForm.vb:

Option Strict On


Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data.OleDb

Public Class frmParentForm
Inherits System.Windows.Forms.Form

Protected frmMain As myAppMain
Protected textIsDirty As Boolean

#Region " Windows Form Designer generated code "

'Public Sub New() ' Default constructor not implemented. Need to pass
the parent form in to work.
' MyBase.New()

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

' 'Add any initialization after the InitializeComponent() call

'End Sub

Public Sub New(ByRef frmMainNew As myAppMain)
MyBase.New()

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

'Add any initialization after the InitializeComponent() call
frmMain = frmMainNew
Call BindAndLoadControls()
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
... code removed for brevity
#End Region

... other common functions here

End Class



frmChildForm.vb:
Option Strict On


Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data.OleDb

Public Class frmUserAdmin
Inherits MyAppTest.frmParentForm

Private dsUserList As New DataSet
Private dsUserData As New DataSet
Private dsPermissions As New DataSet
Private permsList As DataTable

#Region " Windows Form Designer generated code "

'Public Sub New() 'Default constructor not implemented. Need to pass in
main form to work.
' MyBase.New()

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

' 'Add any initialization after the InitializeComponent() call

'End Sub

Public Sub New(ByRef frmMainNew As NITSSMain)
MyBase.New(frmMainNew)

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

'Add any initialization after the InitializeComponent() call
frmMain = frmMainNew
Call BindAndLoadControls()
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
... Code removed for brevity

#End Region

... code removed for brevity
End Class

Re: Exception trying to instansiate an inherited form by Sijin

Sijin
Wed Sep 29 12:18:20 CDT 2004

You parent form needs to have a default constructor explicitly defined.
i.e a constructor that takes no parameter.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph


Ron L wrote:
> I have created a form for my application. Once the form was working, I
> copied that form to a new form that would contain all the common elements of
> all forms in my application and made the existing form inherit from the
> common one. Now when I try to run my application I get the following error
> when I open the form:
>
> An exception occurred while trying to create an instance of
> WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
> MyAppTest.frmParentForm not found.".
>
> The relevant code for the 2 classes is included below. Can anyone tell me
> what I am doing wrong here. As far as I can tell, I have the constructor
> for both defined.
>
> TIA
> Ron L
>
>
> frmParentForm.vb:
>
> Option Strict On
>
>
> Imports System
> Imports System.Drawing
> Imports System.Collections
> Imports System.ComponentModel
> Imports System.Windows.Forms
> Imports System.Data.OleDb
>
> Public Class frmParentForm
> Inherits System.Windows.Forms.Form
>
> Protected frmMain As myAppMain
> Protected textIsDirty As Boolean
>
> #Region " Windows Form Designer generated code "
>
> 'Public Sub New() ' Default constructor not implemented. Need to pass
> the parent form in to work.
> ' MyBase.New()
>
> ' 'This call is required by the Windows Form Designer.
> ' InitializeComponent()
>
> ' 'Add any initialization after the InitializeComponent() call
>
> 'End Sub
>
> Public Sub New(ByRef frmMainNew As myAppMain)
> MyBase.New()
>
> 'This call is required by the Windows Form Designer.
> InitializeComponent()
>
> 'Add any initialization after the InitializeComponent() call
> frmMain = frmMainNew
> Call BindAndLoadControls()
> 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
> ... code removed for brevity
> #End Region
>
> ... other common functions here
>
> End Class
>
>
>
> frmChildForm.vb:
> Option Strict On
>
>
> Imports System
> Imports System.Drawing
> Imports System.Collections
> Imports System.ComponentModel
> Imports System.Windows.Forms
> Imports System.Data.OleDb
>
> Public Class frmUserAdmin
> Inherits MyAppTest.frmParentForm
>
> Private dsUserList As New DataSet
> Private dsUserData As New DataSet
> Private dsPermissions As New DataSet
> Private permsList As DataTable
>
> #Region " Windows Form Designer generated code "
>
> 'Public Sub New() 'Default constructor not implemented. Need to pass in
> main form to work.
> ' MyBase.New()
>
> ' 'This call is required by the Windows Form Designer.
> ' InitializeComponent()
>
> ' 'Add any initialization after the InitializeComponent() call
>
> 'End Sub
>
> Public Sub New(ByRef frmMainNew As NITSSMain)
> MyBase.New(frmMainNew)
>
> 'This call is required by the Windows Form Designer.
> InitializeComponent()
>
> 'Add any initialization after the InitializeComponent() call
> frmMain = frmMainNew
> Call BindAndLoadControls()
> 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
> ... Code removed for brevity
>
> #End Region
>
> ... code removed for brevity
> End Class
>
>
>

Re: Exception trying to instansiate an inherited form by Ron

Ron
Wed Sep 29 12:32:39 CDT 2004

Sijin
Thanks for the response. I had tried that before with no luck, but I
tried again. I get the same error with both constructors. Do you have any
other suggestions?

Ron L


"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
news:O8NONikpEHA.3712@TK2MSFTNGP15.phx.gbl...
> You parent form needs to have a default constructor explicitly defined.
> i.e a constructor that takes no parameter.
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
>
> Ron L wrote:
>> I have created a form for my application. Once the form was working, I
>> copied that form to a new form that would contain all the common elements
>> of all forms in my application and made the existing form inherit from
>> the common one. Now when I try to run my application I get the following
>> error when I open the form:
>>
>> An exception occurred while trying to create an instance of
>> WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
>> MyAppTest.frmParentForm not found.".
>>
>> The relevant code for the 2 classes is included below. Can anyone tell
>> me what I am doing wrong here. As far as I can tell, I have the
>> constructor for both defined.
>>
>> TIA
>> Ron L
>>
>>
>> frmParentForm.vb:
>>
>> Option Strict On
>>
>>
>> Imports System
>> Imports System.Drawing
>> Imports System.Collections
>> Imports System.ComponentModel
>> Imports System.Windows.Forms
>> Imports System.Data.OleDb
>>
>> Public Class frmParentForm
>> Inherits System.Windows.Forms.Form
>>
>> Protected frmMain As myAppMain
>> Protected textIsDirty As Boolean
>>
>> #Region " Windows Form Designer generated code "
>>
>> 'Public Sub New() ' Default constructor not implemented. Need to
>> pass the parent form in to work.
>> ' MyBase.New()
>>
>> ' 'This call is required by the Windows Form Designer.
>> ' InitializeComponent()
>>
>> ' 'Add any initialization after the InitializeComponent() call
>>
>> 'End Sub
>>
>> Public Sub New(ByRef frmMainNew As myAppMain)
>> MyBase.New()
>>
>> 'This call is required by the Windows Form Designer.
>> InitializeComponent()
>>
>> 'Add any initialization after the InitializeComponent() call
>> frmMain = frmMainNew
>> Call BindAndLoadControls()
>> 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
>> ... code removed for brevity
>> #End Region
>>
>> ... other common functions here
>>
>> End Class
>>
>>
>>
>> frmChildForm.vb:
>> Option Strict On
>>
>>
>> Imports System
>> Imports System.Drawing
>> Imports System.Collections
>> Imports System.ComponentModel
>> Imports System.Windows.Forms
>> Imports System.Data.OleDb
>>
>> Public Class frmUserAdmin
>> Inherits MyAppTest.frmParentForm
>>
>> Private dsUserList As New DataSet
>> Private dsUserData As New DataSet
>> Private dsPermissions As New DataSet
>> Private permsList As DataTable
>>
>> #Region " Windows Form Designer generated code "
>>
>> 'Public Sub New() 'Default constructor not implemented. Need to pass
>> in main form to work.
>> ' MyBase.New()
>>
>> ' 'This call is required by the Windows Form Designer.
>> ' InitializeComponent()
>>
>> ' 'Add any initialization after the InitializeComponent() call
>>
>> 'End Sub
>>
>> Public Sub New(ByRef frmMainNew As NITSSMain)
>> MyBase.New(frmMainNew)
>>
>> 'This call is required by the Windows Form Designer.
>> InitializeComponent()
>>
>> 'Add any initialization after the InitializeComponent() call
>> frmMain = frmMainNew
>> Call BindAndLoadControls()
>> 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
>> ... Code removed for brevity
>>
>> #End Region
>>
>> ... code removed for brevity
>> End Class
>>
>>


Re: Exception trying to instansiate an inherited form by Sijin

Sijin
Thu Sep 30 02:01:58 CDT 2004

Hi Ron,

Where is the code for the class WebWinFormTry1.frmNITSSForm the error is
being thrown for that class?

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph


Ron L wrote:
> Sijin
> Thanks for the response. I had tried that before with no luck, but I
> tried again. I get the same error with both constructors. Do you have any
> other suggestions?
>
> Ron L
>
>
> "Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
> news:O8NONikpEHA.3712@TK2MSFTNGP15.phx.gbl...
>
>>You parent form needs to have a default constructor explicitly defined.
>>i.e a constructor that takes no parameter.
>>
>>Sijin Joseph
>>http://www.indiangeek.net
>>http://weblogs.asp.net/sjoseph
>>
>>
>>Ron L wrote:
>>
>>>I have created a form for my application. Once the form was working, I
>>>copied that form to a new form that would contain all the common elements
>>>of all forms in my application and made the existing form inherit from
>>>the common one. Now when I try to run my application I get the following
>>>error when I open the form:
>>>
>>> An exception occurred while trying to create an instance of
>>>WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
>>>MyAppTest.frmParentForm not found.".
>>>
>>>The relevant code for the 2 classes is included below. Can anyone tell
>>>me what I am doing wrong here. As far as I can tell, I have the
>>>constructor for both defined.
>>>
>>>TIA
>>>Ron L
>>>
>>>
>>>frmParentForm.vb:
>>>
>>>Option Strict On
>>>
>>>
>>>Imports System
>>>Imports System.Drawing
>>>Imports System.Collections
>>>Imports System.ComponentModel
>>>Imports System.Windows.Forms
>>>Imports System.Data.OleDb
>>>
>>>Public Class frmParentForm
>>> Inherits System.Windows.Forms.Form
>>>
>>> Protected frmMain As myAppMain
>>> Protected textIsDirty As Boolean
>>>
>>>#Region " Windows Form Designer generated code "
>>>
>>> 'Public Sub New() ' Default constructor not implemented. Need to
>>>pass the parent form in to work.
>>> ' MyBase.New()
>>>
>>> ' 'This call is required by the Windows Form Designer.
>>> ' InitializeComponent()
>>>
>>> ' 'Add any initialization after the InitializeComponent() call
>>>
>>> 'End Sub
>>>
>>> Public Sub New(ByRef frmMainNew As myAppMain)
>>> MyBase.New()
>>>
>>> 'This call is required by the Windows Form Designer.
>>> InitializeComponent()
>>>
>>> 'Add any initialization after the InitializeComponent() call
>>> frmMain = frmMainNew
>>> Call BindAndLoadControls()
>>> 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
>>>... code removed for brevity
>>>#End Region
>>>
>>>... other common functions here
>>>
>>>End Class
>>>
>>>
>>>
>>>frmChildForm.vb:
>>>Option Strict On
>>>
>>>
>>>Imports System
>>>Imports System.Drawing
>>>Imports System.Collections
>>>Imports System.ComponentModel
>>>Imports System.Windows.Forms
>>>Imports System.Data.OleDb
>>>
>>>Public Class frmUserAdmin
>>> Inherits MyAppTest.frmParentForm
>>>
>>> Private dsUserList As New DataSet
>>> Private dsUserData As New DataSet
>>> Private dsPermissions As New DataSet
>>> Private permsList As DataTable
>>>
>>>#Region " Windows Form Designer generated code "
>>>
>>> 'Public Sub New() 'Default constructor not implemented. Need to pass
>>>in main form to work.
>>> ' MyBase.New()
>>>
>>> ' 'This call is required by the Windows Form Designer.
>>> ' InitializeComponent()
>>>
>>> ' 'Add any initialization after the InitializeComponent() call
>>>
>>> 'End Sub
>>>
>>> Public Sub New(ByRef frmMainNew As NITSSMain)
>>> MyBase.New(frmMainNew)
>>>
>>> 'This call is required by the Windows Form Designer.
>>> InitializeComponent()
>>>
>>> 'Add any initialization after the InitializeComponent() call
>>> frmMain = frmMainNew
>>> Call BindAndLoadControls()
>>> 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
>>>... Code removed for brevity
>>>
>>>#End Region
>>>
>>>... code removed for brevity
>>>End Class
>>>
>>>
>
>

Re: Exception trying to instansiate an inherited form by Ron

Ron
Thu Sep 30 06:46:54 CDT 2004

Sijin
I just realized <embarrased> that the "error" I was seeing was the #$$%^
task list. However, I do have a problem with the form in design view. When
I try to look at the child form frmChildForm [Design] in the IDE I get the
following error message:

An error occurred while loading the document. Fix the error, and then
try loading the document again. The error message follows:
Object reference not set to an instance of an object

Thanks and sorry for the red herring.

Ron L

"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
news:e6vLcurpEHA.692@TK2MSFTNGP12.phx.gbl...
> Hi Ron,
>
> Where is the code for the class WebWinFormTry1.frmNITSSForm the error is
> being thrown for that class?
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
>
> Ron L wrote:
>> Sijin
>> Thanks for the response. I had tried that before with no luck, but I
>> tried again. I get the same error with both constructors. Do you have
>> any other suggestions?
>>
>> Ron L
>>
>>
>> "Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
>> news:O8NONikpEHA.3712@TK2MSFTNGP15.phx.gbl...
>>
>>>You parent form needs to have a default constructor explicitly defined.
>>>i.e a constructor that takes no parameter.
>>>
>>>Sijin Joseph
>>>http://www.indiangeek.net
>>>http://weblogs.asp.net/sjoseph
>>>
>>>
>>>Ron L wrote:
>>>
>>>>I have created a form for my application. Once the form was working, I
>>>>copied that form to a new form that would contain all the common
>>>>elements of all forms in my application and made the existing form
>>>>inherit from the common one. Now when I try to run my application I get
>>>>the following error when I open the form:
>>>>
>>>> An exception occurred while trying to create an instance of
>>>> WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
>>>> MyAppTest.frmParentForm not found.".
>>>>
>>>>The relevant code for the 2 classes is included below. Can anyone tell
>>>>me what I am doing wrong here. As far as I can tell, I have the
>>>>constructor for both defined.
>>>>
>>>>TIA
>>>>Ron L
>>>>
>>>>
>>>>frmParentForm.vb:
>>>>
>>>>Option Strict On
>>>>
>>>>
>>>>Imports System
>>>>Imports System.Drawing
>>>>Imports System.Collections
>>>>Imports System.ComponentModel
>>>>Imports System.Windows.Forms
>>>>Imports System.Data.OleDb
>>>>
>>>>Public Class frmParentForm
>>>> Inherits System.Windows.Forms.Form
>>>>
>>>> Protected frmMain As myAppMain
>>>> Protected textIsDirty As Boolean
>>>>
>>>>#Region " Windows Form Designer generated code "
>>>>
>>>> 'Public Sub New() ' Default constructor not implemented. Need to
>>>> pass the parent form in to work.
>>>> ' MyBase.New()
>>>>
>>>> ' 'This call is required by the Windows Form Designer.
>>>> ' InitializeComponent()
>>>>
>>>> ' 'Add any initialization after the InitializeComponent() call
>>>>
>>>> 'End Sub
>>>>
>>>> Public Sub New(ByRef frmMainNew As myAppMain)
>>>> MyBase.New()
>>>>
>>>> 'This call is required by the Windows Form Designer.
>>>> InitializeComponent()
>>>>
>>>> 'Add any initialization after the InitializeComponent() call
>>>> frmMain = frmMainNew
>>>> Call BindAndLoadControls()
>>>> 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
>>>>... code removed for brevity
>>>>#End Region
>>>>
>>>>... other common functions here
>>>>
>>>>End Class
>>>>
>>>>
>>>>
>>>>frmChildForm.vb:
>>>>Option Strict On
>>>>
>>>>
>>>>Imports System
>>>>Imports System.Drawing
>>>>Imports System.Collections
>>>>Imports System.ComponentModel
>>>>Imports System.Windows.Forms
>>>>Imports System.Data.OleDb
>>>>
>>>>Public Class frmUserAdmin
>>>> Inherits MyAppTest.frmParentForm
>>>>
>>>> Private dsUserList As New DataSet
>>>> Private dsUserData As New DataSet
>>>> Private dsPermissions As New DataSet
>>>> Private permsList As DataTable
>>>>
>>>>#Region " Windows Form Designer generated code "
>>>>
>>>> 'Public Sub New() 'Default constructor not implemented. Need to
>>>> pass in main form to work.
>>>> ' MyBase.New()
>>>>
>>>> ' 'This call is required by the Windows Form Designer.
>>>> ' InitializeComponent()
>>>>
>>>> ' 'Add any initialization after the InitializeComponent() call
>>>>
>>>> 'End Sub
>>>>
>>>> Public Sub New(ByRef frmMainNew As NITSSMain)
>>>> MyBase.New(frmMainNew)
>>>>
>>>> 'This call is required by the Windows Form Designer.
>>>> InitializeComponent()
>>>>
>>>> 'Add any initialization after the InitializeComponent() call
>>>> frmMain = frmMainNew
>>>> Call BindAndLoadControls()
>>>> 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
>>>>... Code removed for brevity
>>>>
>>>>#End Region
>>>>
>>>>... code removed for brevity
>>>>End Class
>>>>
>>>>
>>


Re: Exception trying to instansiate an inherited form by Sijin

Sijin
Thu Sep 30 07:15:46 CDT 2004

Does the error in Design View occur even after writing a default
constructor for the child form?

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph


Ron L wrote:
> Sijin
> I just realized <embarrased> that the "error" I was seeing was the #$$%^
> task list. However, I do have a problem with the form in design view. When
> I try to look at the child form frmChildForm [Design] in the IDE I get the
> following error message:
>
> An error occurred while loading the document. Fix the error, and then
> try loading the document again. The error message follows:
> Object reference not set to an instance of an object
>
> Thanks and sorry for the red herring.
>
> Ron L
>
> "Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
> news:e6vLcurpEHA.692@TK2MSFTNGP12.phx.gbl...
>
>>Hi Ron,
>>
>>Where is the code for the class WebWinFormTry1.frmNITSSForm the error is
>>being thrown for that class?
>>
>>Sijin Joseph
>>http://www.indiangeek.net
>>http://weblogs.asp.net/sjoseph
>>
>>
>>Ron L wrote:
>>
>>>Sijin
>>> Thanks for the response. I had tried that before with no luck, but I
>>>tried again. I get the same error with both constructors. Do you have
>>>any other suggestions?
>>>
>>>Ron L
>>>
>>>
>>>"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
>>>news:O8NONikpEHA.3712@TK2MSFTNGP15.phx.gbl...
>>>
>>>
>>>>You parent form needs to have a default constructor explicitly defined.
>>>>i.e a constructor that takes no parameter.
>>>>
>>>>Sijin Joseph
>>>>http://www.indiangeek.net
>>>>http://weblogs.asp.net/sjoseph
>>>>
>>>>
>>>>Ron L wrote:
>>>>
>>>>
>>>>>I have created a form for my application. Once the form was working, I
>>>>>copied that form to a new form that would contain all the common
>>>>>elements of all forms in my application and made the existing form
>>>>>inherit from the common one. Now when I try to run my application I get
>>>>>the following error when I open the form:
>>>>>
>>>>>An exception occurred while trying to create an instance of
>>>>>WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
>>>>>MyAppTest.frmParentForm not found.".
>>>>>
>>>>>The relevant code for the 2 classes is included below. Can anyone tell
>>>>>me what I am doing wrong here. As far as I can tell, I have the
>>>>>constructor for both defined.
>>>>>
>>>>>TIA
>>>>>Ron L
>>>>>
>>>>>
>>>>>frmParentForm.vb:
>>>>>
>>>>>Option Strict On
>>>>>
>>>>>
>>>>>Imports System
>>>>>Imports System.Drawing
>>>>>Imports System.Collections
>>>>>Imports System.ComponentModel
>>>>>Imports System.Windows.Forms
>>>>>Imports System.Data.OleDb
>>>>>
>>>>>Public Class frmParentForm
>>>>> Inherits System.Windows.Forms.Form
>>>>>
>>>>> Protected frmMain As myAppMain
>>>>> Protected textIsDirty As Boolean
>>>>>
>>>>>#Region " Windows Form Designer generated code "
>>>>>
>>>>> 'Public Sub New() ' Default constructor not implemented. Need to
>>>>>pass the parent form in to work.
>>>>> ' MyBase.New()
>>>>>
>>>>> ' 'This call is required by the Windows Form Designer.
>>>>> ' InitializeComponent()
>>>>>
>>>>> ' 'Add any initialization after the InitializeComponent() call
>>>>>
>>>>> 'End Sub
>>>>>
>>>>> Public Sub New(ByRef frmMainNew As myAppMain)
>>>>> MyBase.New()
>>>>>
>>>>> 'This call is required by the Windows Form Designer.
>>>>> InitializeComponent()
>>>>>
>>>>> 'Add any initialization after the InitializeComponent() call
>>>>> frmMain = frmMainNew
>>>>> Call BindAndLoadControls()
>>>>> 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
>>>>>... code removed for brevity
>>>>>#End Region
>>>>>
>>>>>... other common functions here
>>>>>
>>>>>End Class
>>>>>
>>>>>
>>>>>
>>>>>frmChildForm.vb:
>>>>>Option Strict On
>>>>>
>>>>>
>>>>>Imports System
>>>>>Imports System.Drawing
>>>>>Imports System.Collections
>>>>>Imports System.ComponentModel
>>>>>Imports System.Windows.Forms
>>>>>Imports System.Data.OleDb
>>>>>
>>>>>Public Class frmUserAdmin
>>>>> Inherits MyAppTest.frmParentForm
>>>>>
>>>>> Private dsUserList As New DataSet
>>>>> Private dsUserData As New DataSet
>>>>> Private dsPermissions As New DataSet
>>>>> Private permsList As DataTable
>>>>>
>>>>>#Region " Windows Form Designer generated code "
>>>>>
>>>>> 'Public Sub New() 'Default constructor not implemented. Need to
>>>>>pass in main form to work.
>>>>> ' MyBase.New()
>>>>>
>>>>> ' 'This call is required by the Windows Form Designer.
>>>>> ' InitializeComponent()
>>>>>
>>>>> ' 'Add any initialization after the InitializeComponent() call
>>>>>
>>>>> 'End Sub
>>>>>
>>>>> Public Sub New(ByRef frmMainNew As NITSSMain)
>>>>> MyBase.New(frmMainNew)
>>>>>
>>>>> 'This call is required by the Windows Form Designer.
>>>>> InitializeComponent()
>>>>>
>>>>> 'Add any initialization after the InitializeComponent() call
>>>>> frmMain = frmMainNew
>>>>> Call BindAndLoadControls()
>>>>> 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
>>>>>... Code removed for brevity
>>>>>
>>>>>#End Region
>>>>>
>>>>>... code removed for brevity
>>>>>End Class
>>>>>
>>>>>
>>>
>

Re: Exception trying to instansiate an inherited form by Ron

Ron
Thu Sep 30 07:36:06 CDT 2004

Yes.

Ron L

"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
news:%234vMydupEHA.4004@TK2MSFTNGP10.phx.gbl...
> Does the error in Design View occur even after writing a default
> constructor for the child form?
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
>
> Ron L wrote:
>> Sijin
>> I just realized <embarrased> that the "error" I was seeing was the
>> #$$%^ task list. However, I do have a problem with the form in design
>> view. When I try to look at the child form frmChildForm [Design] in the
>> IDE I get the following error message:
>>
>> An error occurred while loading the document. Fix the error, and
>> then try loading the document again. The error message follows:
>> Object reference not set to an instance of an object
>>
>> Thanks and sorry for the red herring.
>>
>> Ron L
>>
>> "Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
>> news:e6vLcurpEHA.692@TK2MSFTNGP12.phx.gbl...
>>
>>>Hi Ron,
>>>
>>>Where is the code for the class WebWinFormTry1.frmNITSSForm the error is
>>>being thrown for that class?
>>>
>>>Sijin Joseph
>>>http://www.indiangeek.net
>>>http://weblogs.asp.net/sjoseph
>>>
>>>
>>>Ron L wrote:
>>>
>>>>Sijin
>>>> Thanks for the response. I had tried that before with no luck, but
>>>> I tried again. I get the same error with both constructors. Do you
>>>> have any other suggestions?
>>>>
>>>>Ron L
>>>>
>>>>
>>>>"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
>>>>news:O8NONikpEHA.3712@TK2MSFTNGP15.phx.gbl...
>>>>
>>>>
>>>>>You parent form needs to have a default constructor explicitly defined.
>>>>>i.e a constructor that takes no parameter.
>>>>>
>>>>>Sijin Joseph
>>>>>http://www.indiangeek.net
>>>>>http://weblogs.asp.net/sjoseph
>>>>>
>>>>>
>>>>>Ron L wrote:
>>>>>
>>>>>
>>>>>>I have created a form for my application. Once the form was working,
>>>>>>I copied that form to a new form that would contain all the common
>>>>>>elements of all forms in my application and made the existing form
>>>>>>inherit from the common one. Now when I try to run my application I
>>>>>>get the following error when I open the form:
>>>>>>
>>>>>>An exception occurred while trying to create an instance of
>>>>>>WebWinFormTry1.frmNITSSForm. The exception was "Constructor on type
>>>>>>MyAppTest.frmParentForm not found.".
>>>>>>
>>>>>>The relevant code for the 2 classes is included below. Can anyone
>>>>>>tell me what I am doing wrong here. As far as I can tell, I have the
>>>>>>constructor for both defined.
>>>>>>
>>>>>>TIA
>>>>>>Ron L
>>>>>>
>>>>>>
>>>>>>frmParentForm.vb:
>>>>>>
>>>>>>Option Strict On
>>>>>>
>>>>>>
>>>>>>Imports System
>>>>>>Imports System.Drawing
>>>>>>Imports System.Collections
>>>>>>Imports System.ComponentModel
>>>>>>Imports System.Windows.Forms
>>>>>>Imports System.Data.OleDb
>>>>>>
>>>>>>Public Class frmParentForm
>>>>>> Inherits System.Windows.Forms.Form
>>>>>>
>>>>>> Protected frmMain As myAppMain
>>>>>> Protected textIsDirty As Boolean
>>>>>>
>>>>>>#Region " Windows Form Designer generated code "
>>>>>>
>>>>>> 'Public Sub New() ' Default constructor not implemented. Need to
>>>>>> pass the parent form in to work.
>>>>>> ' MyBase.New()
>>>>>>
>>>>>> ' 'This call is required by the Windows Form Designer.
>>>>>> ' InitializeComponent()
>>>>>>
>>>>>> ' 'Add any initialization after the InitializeComponent() call
>>>>>>
>>>>>> 'End Sub
>>>>>>
>>>>>> Public Sub New(ByRef frmMainNew As myAppMain)
>>>>>> MyBase.New()
>>>>>>
>>>>>> 'This call is required by the Windows Form Designer.
>>>>>> InitializeComponent()
>>>>>>
>>>>>> 'Add any initialization after the InitializeComponent() call
>>>>>> frmMain = frmMainNew
>>>>>> Call BindAndLoadControls()
>>>>>> 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
>>>>>>... code removed for brevity
>>>>>>#End Region
>>>>>>
>>>>>>... other common functions here
>>>>>>
>>>>>>End Class
>>>>>>
>>>>>>
>>>>>>
>>>>>>frmChildForm.vb:
>>>>>>Option Strict On
>>>>>>
>>>>>>
>>>>>>Imports System
>>>>>>Imports System.Drawing
>>>>>>Imports System.Collections
>>>>>>Imports System.ComponentModel
>>>>>>Imports System.Windows.Forms
>>>>>>Imports System.Data.OleDb
>>>>>>
>>>>>>Public Class frmUserAdmin
>>>>>> Inherits MyAppTest.frmParentForm
>>>>>>
>>>>>> Private dsUserList As New DataSet
>>>>>> Private dsUserData As New DataSet
>>>>>> Private dsPermissions As New DataSet
>>>>>> Private permsList As DataTable
>>>>>>
>>>>>>#Region " Windows Form Designer generated code "
>>>>>>
>>>>>> 'Public Sub New() 'Default constructor not implemented. Need to
>>>>>> pass in main form to work.
>>>>>> ' MyBase.New()
>>>>>>
>>>>>> ' 'This call is required by the Windows Form Designer.
>>>>>> ' InitializeComponent()
>>>>>>
>>>>>> ' 'Add any initialization after the InitializeComponent() call
>>>>>>
>>>>>> 'End Sub
>>>>>>
>>>>>> Public Sub New(ByRef frmMainNew As NITSSMain)
>>>>>> MyBase.New(frmMainNew)
>>>>>>
>>>>>> 'This call is required by the Windows Form Designer.
>>>>>> InitializeComponent()
>>>>>>
>>>>>> 'Add any initialization after the InitializeComponent() call
>>>>>> frmMain = frmMainNew
>>>>>> Call BindAndLoadControls()
>>>>>> 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
>>>>>>... Code removed for brevity
>>>>>>
>>>>>>#End Region
>>>>>>
>>>>>>... code removed for brevity
>>>>>>End Class
>>>>>>
>>>>>>
>>>>
>>