Form designer fails to load inherited form

G

Guest

I have a base form with a few controls, some methods, and some properties
that I inherit from to create three different form classes (in a VB.net 2003
solution, in a lib project along with program and deplyoment projects). When
I first wrote this, all worked just fine.

I created a new inherited form (using Add inherited form ...) and
immediately the newly created form plus any existing forms that inherit from
the same base form no longer display but give the error message, "An error
occured while loading the document. Fix the error, and they try loading the
documen again. The error message follows: Object reference not set to an
instance of an object." I assume that the form designer has failed somehow
when attempting to draw the form in the design mode. The newly created form
never displayed at all.

The base form (and others that don't inherit from it), however, display
without error. Removing the newly created inherited form from the project and
deleting it entirely has not fixed the problem; now I get this error with any
of the inheriting forms.

Yet, the application runs just fine. I tried the trick of closing all
[Design] tabs, and also completely restarting VS with no luck. I ran into
this once before and solved it by recreating the base and inherited forms
from scratch, a time-consuming excercise that I don't wish to repeat.

I am able to recreate a form inheritance example in a separate solution with
no problem, as well.

Does anyone have a fix or some ideas of what to look for?

Thanks,

DrJohn
 
G

Guest

A million thanks "Replying to yourself". I had the same problem, tried all
sorts of things to isolate the issue with no success, but using your
workaround fixed it. Nice work.

Cheers
Jeremy

DrJohn said:
[Replying to myself...]

With some trial-and-error I found that calling a method on the base form
from its own form_load event handler casues this designer snafu, i.e.:

Private Sub frmTestInherit_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
FillCombobox()
End Sub
Friend Sub FillCombobox()
[some code to fill a combobox in this form]
End Sub

The same form_load handler code in a form inheriting from this base doesn't
cause the problem in designer [FillCombo remains in the base class].

-DrJohn

DrJohn said:
I have a base form with a few controls, some methods, and some properties
that I inherit from to create three different form classes (in a VB.net 2003
solution, in a lib project along with program and deplyoment projects). When
I first wrote this, all worked just fine.

I created a new inherited form (using Add inherited form ...) and
immediately the newly created form plus any existing forms that inherit from
the same base form no longer display but give the error message, "An error
occured while loading the document. Fix the error, and they try loading the
documen again. The error message follows: Object reference not set to an
instance of an object." I assume that the form designer has failed somehow
when attempting to draw the form in the design mode. The newly created form
never displayed at all.

The base form (and others that don't inherit from it), however, display
without error. Removing the newly created inherited form from the project and
deleting it entirely has not fixed the problem; now I get this error with any
of the inheriting forms.

Yet, the application runs just fine. I tried the trick of closing all
[Design] tabs, and also completely restarting VS with no luck. I ran into
this once before and solved it by recreating the base and inherited forms
from scratch, a time-consuming excercise that I don't wish to repeat.

I am able to recreate a form inheritance example in a separate solution with
no problem, as well.

Does anyone have a fix or some ideas of what to look for?

Thanks,

DrJohn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top