473,473 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MustInherit give a problem

I create a form

Public Class MyTool

Inherits MyForm

....

which uses:

Public MustInherit Class MyForm

Inherits Form

....

The reason for the MustInherit is that the MyForm contains:
Protected Friend MustOverride Sub SetThis()

And get the error:

The designer must create an instance of type 'Test.Lib.MyForm' but it cannot
because the type is declared as abstract.

If I change to an Overridable sub and remove the MustInherit it works OK.

I prefer the MustOverride because then I can't forget to override it when I
use MyForm.

Can you advise or shed some light on this?
Thanks




Dec 8 '07 #1
4 3244
"Academia" <ac************@a-znet.comschrieb
I create a form

Public Class MyTool

Inherits MyForm

...

which uses:

Public MustInherit Class MyForm

Inherits Form

...

The reason for the MustInherit is that the MyForm contains:
Protected Friend MustOverride Sub SetThis()

And get the error:

The designer must create an instance of type 'Test.Lib.MyForm' but
it cannot because the type is declared as abstract.

If I change to an Overridable sub and remove the MustInherit it
works OK.

I prefer the MustOverride because then I can't forget to override it
when I use MyForm.

Can you advise or shed some light on this?

You can not create an instance of an abstract class, thus the designer
can't, too. You would have to remove "Mustinherit". I don't think there's
another way. If you go for it, you might throw a
System.NotImplementedException in Sub SetThis in the base class. Not what
you're looking for, I know.
Armin

Dec 8 '07 #2
Why is the designer creating an instance of MyForm. I'd think it would
create an instance of MyTool which normally can create a MyForm object.

Thanks
"Armin Zingler" <az*******@freenet.dewrote in message
news:O$**************@TK2MSFTNGP06.phx.gbl...
"Academia" <ac************@a-znet.comschrieb
>I create a form

Public Class MyTool

Inherits MyForm

...

which uses:

Public MustInherit Class MyForm

Inherits Form

...

The reason for the MustInherit is that the MyForm contains:
Protected Friend MustOverride Sub SetThis()

And get the error:

The designer must create an instance of type 'Test.Lib.MyForm' but
it cannot because the type is declared as abstract.

If I change to an Overridable sub and remove the MustInherit it
works OK.

I prefer the MustOverride because then I can't forget to override it
when I use MyForm.

Can you advise or shed some light on this?


You can not create an instance of an abstract class, thus the designer
can't, too. You would have to remove "Mustinherit". I don't think there's
another way. If you go for it, you might throw a
System.NotImplementedException in Sub SetThis in the base class. Not what
you're looking for, I know.
Armin

Dec 8 '07 #3
The designer creates an instance of the base class and then runs the
InitializeComponents method from the current class.

I believe I read that this is fixed in VS2008.

On Sat, 8 Dec 2007 10:48:58 -0500, "Academia"
<ac************@a-znet.comwrote:
>Why is the designer creating an instance of MyForm. I'd think it would
create an instance of MyTool which normally can create a MyForm object.

Thanks
"Armin Zingler" <az*******@freenet.dewrote in message
news:O$**************@TK2MSFTNGP06.phx.gbl...
>"Academia" <ac************@a-znet.comschrieb
>>I create a form

Public Class MyTool

Inherits MyForm

...

which uses:

Public MustInherit Class MyForm

Inherits Form

...

The reason for the MustInherit is that the MyForm contains:
Protected Friend MustOverride Sub SetThis()

And get the error:

The designer must create an instance of type 'Test.Lib.MyForm' but
it cannot because the type is declared as abstract.

If I change to an Overridable sub and remove the MustInherit it
works OK.

I prefer the MustOverride because then I can't forget to override it
when I use MyForm.

Can you advise or shed some light on this?


You can not create an instance of an abstract class, thus the designer
can't, too. You would have to remove "Mustinherit". I don't think there's
another way. If you go for it, you might throw a
System.NotImplementedException in Sub SetThis in the base class. Not what
you're looking for, I know.
Armin
Dec 8 '07 #4
thanks

"Jack Jackson" <ja********@pebbleridge.comwrote in message
news:hf********************************@4ax.com...
The designer creates an instance of the base class and then runs the
InitializeComponents method from the current class.

I believe I read that this is fixed in VS2008.

On Sat, 8 Dec 2007 10:48:58 -0500, "Academia"
<ac************@a-znet.comwrote:
>>Why is the designer creating an instance of MyForm. I'd think it would
create an instance of MyTool which normally can create a MyForm object.

Thanks
"Armin Zingler" <az*******@freenet.dewrote in message
news:O$**************@TK2MSFTNGP06.phx.gbl...
>>"Academia" <ac************@a-znet.comschrieb
I create a form

Public Class MyTool

Inherits MyForm

...

which uses:

Public MustInherit Class MyForm

Inherits Form

...

The reason for the MustInherit is that the MyForm contains:
Protected Friend MustOverride Sub SetThis()

And get the error:

The designer must create an instance of type 'Test.Lib.MyForm' but
it cannot because the type is declared as abstract.

If I change to an Overridable sub and remove the MustInherit it
works OK.

I prefer the MustOverride because then I can't forget to override it
when I use MyForm.

Can you advise or shed some light on this?
You can not create an instance of an abstract class, thus the designer
can't, too. You would have to remove "Mustinherit". I don't think
there's
another way. If you go for it, you might throw a
System.NotImplementedException in Sub SetThis in the base class. Not
what
you're looking for, I know.
Armin

Dec 8 '07 #5

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

Similar topics

0
by: Arthur Dent | last post by:
Q to anyone whose played around with VS2005... Has the bug been fixed which prevents a web form or usercontrol from inheriting off a class defined as MustInherit?? Thanks in advance, - Arthur...
2
by: Arthur Dent | last post by:
Cheers all, Right now in ASP.NET, if you make a base Page class that you use in your app which inherits from System.Web.UI.Page, you cannot declare it as MustInherit, because you wind up with...
1
by: Lance | last post by:
I get an exception when attempting to open a form in design mode if the form inherits from a form that is declared as MustInherit. For example, if I have: Public MustInherit Class TestFormBase...
4
by: Francisco Amaro | last post by:
Hi all, Have question about inheriting a class that has parameters in the constructor such as : Public MustInherit Class MyParentClass Public mystring As String Public Sub New(ByVal...
3
by: Philip Wagenaar | last post by:
I created a Mustinherit class with two must override readonly properties: Public MustInherit Class RequestPart Public MustOverride ReadOnly Property Description() As Boolean Public MustOverride...
2
by: Ray Cassick \(Home\) | last post by:
Since I got such good feedback from the Xml comments question I will ask this of the group as well. Is VS.NET 2005 handling the visual inheritance problems centered around controls and forms...
28
by: Yuri CHUANG | last post by:
"No newline at the end of your output" is really a problem? I've never learned that before. So I desire to know some tips about writting a program perfectly.Can anyone give me some tips which are...
2
by: Joh Smith | last post by:
I have a form called Parent that I mark as abstract (MustInherit). Then I add another form called Child that inherits Parent and implements all Parent abstract methods. It compiles Ok, but when i...
6
by: Joe HM | last post by:
Hello - I have a question regarding overloading the New() in a MustInherit Class. The following show the code in question ... MustInherit Class cAbstract Public MustOverride Sub print() ...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.