473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with inheritance in vb.net

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!
Jul 21 '05 #1
9 2339
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!

Jul 21 '05 #2
* 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/>
Jul 21 '05 #3
"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...
Jul 21 '05 #4
"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!
Jul 21 '05 #5
"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!
Jul 21 '05 #6
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!
Jul 21 '05 #7
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!
Jul 21 '05 #8

"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.
Jul 21 '05 #9

"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.
Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
I have created an MDI child form that I am using as a base form in a VB.Net MDI application. The base MDI child form has a series of menu options on it. I then use this form to create other MDI...
13
by: John Perks and Sarah Mount | last post by:
Trying to create the "lopsided diamond" inheritance below: >>> class B(object):pass >>> class D1(B):pass >>> class D2(D1):pass >>> class D(D1, D2):pass Traceback (most recent call last): File...
4
by: Alex Hunsley | last post by:
I've seen a few discussion about the use of 'super' in Python, including the opinion that 'super' should only be used to solve inheritance diamond problem. (And that a constructor that wants to...
3
by: Roman S. Golubin1709176985 | last post by:
All how do you do! Who what cases uses for C# programming? I have an experience with Microsoft Visio several days. He has a problem with interface inheritance... óan who that other advise? ...
2
by: Darryn Ross | last post by:
Hi.. I have a standard windows app in C#. The project contains a two forms and one class that i have created. I want both of the forms to inherit from the class but i am getting an error reading...
5
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a creating a my own tabpage class (MyTabPage) which inherits the .Net TabPage class. In the relevant event I want to loop through the collection of TabPages and then when I...
1
by: George Durzi | last post by:
I'm converting a c# web application to support page inheritance so that I can really change the look and feel of my application by only modifying the ..cs that my pages inherit from. The only...
1
by: bill | last post by:
What's up with inheritance in code behind? Is it reliable, or should I skip it and forget about using inheritance in web forms until they get it right? I'm using VB.NET 2005 I have a web form...
2
by: beseecher | last post by:
Hi, In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: ...
3
by: djboyse | last post by:
Hey, I'm kind of new to C++ and having some problems with inheritance. I've tried looking everywhere for some help, but I'm not too sure what to ask so please any input will be greatly...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.