Using MustInerit with Forms

  • Thread starter Thread starter nate axtell
  • Start date Start date
N

nate axtell

Using VB.NET 2003 in Visual Studio...
I have created a base Form class ProjectA.FormA, that I inherit in another
class called ProjectB.FormB. FormA is declared as MustInherit. When I try
to view the inheriting class FormB in the Visual Studio Designer I see the
error:
"The designer must create and instance of 'ProjectA.FormA' but it cannot
because the type is declared as abstract."
If I remove the MustInherit and rebuild ProjectA then FormB is displayed
without the error. Has anyone found a way to use MustInherit in a base
class definition and then view the inheriting forms in the designer?
thanks,
nate
 
nate axtell said:
I have created a base Form class ProjectA.FormA, that I inherit in another
class called ProjectB.FormB. FormA is declared as MustInherit. When I
try to view the inheriting class FormB in the Visual Studio Designer I see
the error:
"The designer must create and instance of 'ProjectA.FormA' but it cannot
because the type is declared as abstract."
If I remove the MustInherit and rebuild ProjectA then FormB is displayed
without the error. Has anyone found a way to use MustInherit in a base
class definition and then view the inheriting forms in the designer?

That's a known limitation of the designer. You can partially work around it
by using this code:

\\\

' In the project properties the checkbox that defines the
' 'DEBUG' constant must be checked.
#If DEBUG Then
Public Class Foo
#Else
Public MustInherit Class Foo
#End If
...
End Class
///

In release mode the class will be 'MustInherit'.
 
Back
Top