473,503 Members | 11,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!
Nov 20 '05 #1
6 2471
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
* 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
"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
"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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3079
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
3255
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
2739
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
2633
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
3918
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
1652
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
1412
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
1269
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
2075
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
1445
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
7194
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
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.