By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

Problems with inheritance in vb.net

P: n/a
Hi, all.
I'm having a problem which vb developers had for certain al least
once.

I have my base form, declared as musthinherit;

Public MustInherit Class frmsdvPrincipal

....

and my child form, declared as inherited;

Public Class frmsdvEtiquetas
Inherits SDV.UL.Principal.frmsdvPrincipal

....

In run-time, frmsdvEtiquetas runs perfect, but in design time, this
error occurs;

"The designer must create an instance of type
'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is
declared as abstract"

I've tryed several tips like deleting the reference and adding it
again and excluding the child form and including it again, but nothing
works....

Can someone help me? What am i doing wrong?

URGENT!!!

Thanks in advance!
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I think this is a designer issue. Don't make the base class abstract and it
should go away.

"Pedro" <pn**@portugalmail.pt> wrote in message
news:9f**************************@posting.google.c om...
Hi, all.
I'm having a problem which vb developers had for certain al least
once.

I have my base form, declared as musthinherit;

Public MustInherit Class frmsdvPrincipal

...

and my child form, declared as inherited;

Public Class frmsdvEtiquetas
Inherits SDV.UL.Principal.frmsdvPrincipal

...

In run-time, frmsdvEtiquetas runs perfect, but in design time, this
error occurs;

"The designer must create an instance of type
'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is
declared as abstract"

I've tryed several tips like deleting the reference and adding it
again and excluding the child form and including it again, but nothing
works....

Can someone help me? What am i doing wrong?

URGENT!!!

Thanks in advance!

Nov 20 '05 #2

P: n/a
* pn**@portugalmail.pt (Pedro) scripsit:
I have my base form, declared as musthinherit;

Public MustInherit Class frmsdvPrincipal

...

and my child form, declared as inherited;

Public Class frmsdvEtiquetas
Inherits SDV.UL.Principal.frmsdvPrincipal

...

In run-time, frmsdvEtiquetas runs perfect, but in design time, this
error occurs;

"The designer must create an instance of type
'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is
declared as abstract"


You cannot edit a form that inherits from a mustinherit form in the
windows forms designer because the designer must be able to instantiate
the base class.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

P: n/a
"David Williams" <Da***********@discussions.microsoft.com> wrote in message news:<99**********************************@microso ft.com>...
What I tend to do when I run into issues like this (which is as Herfried stated, you can not design a form that inherits from a MustInherit class,) is to do something like:

#If DEBUG Then
Public Class fmsdvPrincipal
#Else
Public MustInherit frmsdvPrincipal
#End If

However, there MIGHT be a problem with that in this case. If the class has any routines that you marked as MustOverride, you will have to change them, possiblly by wrapping in an #If as above, to Overridable and give no implementation details.

HTH
--
David Williams, VB.NET MVP
"Herfried K. Wagner [MVP]" wrote:
* pn**@portugalmail.pt (Pedro) scripsit:
I have my base form, declared as musthinherit;

Public MustInherit Class frmsdvPrincipal

...

and my child form, declared as inherited;

Public Class frmsdvEtiquetas
Inherits SDV.UL.Principal.frmsdvPrincipal

...

In run-time, frmsdvEtiquetas runs perfect, but in design time, this
error occurs;

"The designer must create an instance of type
'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is
declared as abstract"


You cannot edit a form that inherits from a mustinherit form in the
windows forms designer because the designer must be able to instantiate
the base class.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Thanks David;

Your suggestion works, but when i run my solution, a similar problem
with base form occurs.

Sometimes i have to comment the #if #else #endif code, close the
solution, open it again and both base and child form appears to open
in design mode.
After running my project once, the problem with child form appears...
That's when i uncomment the #if #else #endif code to resolve it. And
so on, and so on... Basically, i can have my base and child form
running on design mode, but only when i follow this steps and before
running my project.

Is this normal?

Thanks for the tip David...
Nov 20 '05 #4

P: n/a
"David Williams" <Da***********@discussions.microsoft.com> wrote in message news:<99**********************************@microso ft.com>...
What I tend to do when I run into issues like this (which is as Herfried stated, you can not design a form that inherits from a MustInherit class,) is to do something like:

#If DEBUG Then
Public Class fmsdvPrincipal
#Else
Public MustInherit frmsdvPrincipal
#End If

However, there MIGHT be a problem with that in this case. If the class has any routines that you marked as MustOverride, you will have to change them, possiblly by wrapping in an #If as above, to Overridable and give no implementation details.

HTH
--
David Williams, VB.NET MVP
"Herfried K. Wagner [MVP]" wrote:
* pn**@portugalmail.pt (Pedro) scripsit:
I have my base form, declared as musthinherit;

Public MustInherit Class frmsdvPrincipal

...

and my child form, declared as inherited;

Public Class frmsdvEtiquetas
Inherits SDV.UL.Principal.frmsdvPrincipal

...

In run-time, frmsdvEtiquetas runs perfect, but in design time, this
error occurs;

"The designer must create an instance of type
'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is
declared as abstract"


You cannot edit a form that inherits from a mustinherit form in the
windows forms designer because the designer must be able to instantiate
the base class.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Hi!

I think i figure a way to control this inheritance issue in design/run
time, with your advances, but this design issue in vb.net is very
anoying! Now, i can't see my child form controls in run-time. They
appear normally in design but not in run-time! Why?

Any ideas?

Thanks in advance!
Nov 20 '05 #5

P: n/a
pn**@portugalmail.pt (Pedro) wrote in message news:<9f**************************@posting.google. com>...
"David Williams" <Da***********@discussions.microsoft.com> wrote in message news:<99**********************************@microso ft.com>...
What I tend to do when I run into issues like this (which is as Herfried stated, you can not design a form that inherits from a MustInherit class,) is to do something like:

#If DEBUG Then
Public Class fmsdvPrincipal
#Else
Public MustInherit frmsdvPrincipal
#End If

However, there MIGHT be a problem with that in this case. If the class has any routines that you marked as MustOverride, you will have to change them, possiblly by wrapping in an #If as above, to Overridable and give no implementation details.

HTH
--
David Williams, VB.NET MVP
"Herfried K. Wagner [MVP]" wrote:
* pn**@portugalmail.pt (Pedro) scripsit:
> I have my base form, declared as musthinherit;
>
> Public MustInherit Class frmsdvPrincipal
>
> ...
>
> and my child form, declared as inherited;
>
> Public Class frmsdvEtiquetas
> Inherits SDV.UL.Principal.frmsdvPrincipal
>
> ...
>
> In run-time, frmsdvEtiquetas runs perfect, but in design time, this
> error occurs;
>
> "The designer must create an instance of type
> 'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is
> declared as abstract"

You cannot edit a form that inherits from a mustinherit form in the
windows forms designer because the designer must be able to instantiate
the base class.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Hi!

I think i figure a way to control this inheritance issue in design/run
time, with your advances, but this design issue in vb.net is very
anoying! Now, i can't see my child form controls in run-time. They
appear normally in design but not in run-time! Why?

Any ideas?

Thanks in advance!


Sorry i wasn't very specific in the latest post! My child form
inherits anything from my base form. What i want is to add some
controls (not inherited) to my child form, but they only appear in
design! Why is that?

Help needed!

Thanks in advance!
Nov 20 '05 #6

P: n/a

"Pedro" <pn**@portugalmail.pt> wrote in message
news:9f**************************@posting.google.c om...
pn**@portugalmail.pt (Pedro) wrote in message

news:<9f**************************@posting.google. com>...
"David Williams" <Da***********@discussions.microsoft.com> wrote in message news:<99**********************************@microso ft.com>...
What I tend to do when I run into issues like this (which is as Herfried stated, you can not design a form that inherits from a MustInherit
class,) is to do something like:
#If DEBUG Then
Public Class fmsdvPrincipal
#Else
Public MustInherit frmsdvPrincipal
#End If

However, there MIGHT be a problem with that in this case. If the class has any routines that you marked as MustOverride, you will have to
change them, possiblly by wrapping in an #If as above, to Overridable and
give no implementation details.
HTH
--
David Williams, VB.NET MVP
"Herfried K. Wagner [MVP]" wrote:

> * pn**@portugalmail.pt (Pedro) scripsit:
> > I have my base form, declared as musthinherit;
> >
> > Public MustInherit Class frmsdvPrincipal
> >
> > ...
> >
> > and my child form, declared as inherited;
> >
> > Public Class frmsdvEtiquetas
> > Inherits SDV.UL.Principal.frmsdvPrincipal
> >
> > ...
> >
> > In run-time, frmsdvEtiquetas runs perfect, but in design time, this > > error occurs;
> >
> > "The designer must create an instance of type
> > 'SDV.UL.Principal.frmsdvPrincipal' but it cannot because the type is > > declared as abstract"
>
> You cannot edit a form that inherits from a mustinherit form in the
> windows forms designer because the designer must be able to instantiate > the base class.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>

Hi!

I think i figure a way to control this inheritance issue in design/run
time, with your advances, but this design issue in vb.net is very
anoying! Now, i can't see my child form controls in run-time. They
appear normally in design but not in run-time! Why?

Any ideas?

Thanks in advance!


Sorry i wasn't very specific in the latest post! My child form
inherits anything from my base form. What i want is to add some
controls (not inherited) to my child form, but they only appear in
design! Why is that?

Help needed!
Thanks in advance!


Are you adding the controls to a panel or other container? If so, you need
to make sure the container control's modifier is not set to Private in the
base form (preferably, it would be set to Protected). The behavior you
describe happens when the modifier is set to Private.
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.