473,749 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MustInherit and Design Mode

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
Inherits Windows.Forms.F orm
'...Normal Windows Form Designer generated code here
Public MustOverride Function GetValue() As Integer
End Class

Public Class TestForm
Inherits TestFormBase
'...Normal Windows Form Designer generated code here
Public Overrides Function GetValue() As Integer
Return 100
End Function
End Class

Then I get the following exception when I attempt to open
TestForm in design mode:

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

Curiously, I do not get an exception if I open
TestFormBase in the designer.

Is there any way to avoid this exception?

Thanks,
Lance
Nov 20 '05 #1
1 1536
Lance,
Is there any way to avoid this exception?


I would do something like this

#If DEBUG Then
Public Class TestFormBase
#Else
Public MustInherit Class TestFormBase
#End If

#If DEBUG Then
Public Overridable Function GetValue() As Integer
Throw New NotImplementedE xception
End Function
#Else
Public MustOverride Function GetValue() As Integer
#End If

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #2

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

Similar topics

4
5891
by: Jeff | last post by:
I have a need to open a report in design mode immediately before opening it in preview, to change the Minimum and Maximum scale on an axis on a chart. This results in a flash of the report in design mode just before it is opened in preview mode. Is there any way to open it in design mode hidden? Jeff
4
2103
by: jim | last post by:
I am trying to debug a user written web control and web control designer. I found an article “Building Windows Forms Controls and Component with Rich Design-Time Features†that describes how to setup debugging for a Windows Form control. I cannot find any documentation or articles on setting up the same facility for a Web control. Any help on setting the control library project to debug the design-time code would be greatly...
3
2765
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 ReadOnly Property Mandatory() As String End Class I the derived class I cannot override the property Mandatory because the return types differ:
2
2195
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 that are decorated with MustInherit any better than 2003 did? I am getting really tired of having to do the good old '#If DEBUG Then' workaround just to get by this.
3
1704
by: Rolf Welskes | last post by:
Hello, for a large web site project we would like to use nested Master Pages. Unfortunely VS2005 is not able to show pages in design mode when nested Master pages are used. This has the consequence that also each content page cannot be used in design mode. It is impossible to design hundrets of pages in source mode without design
0
1102
by: Timje | last post by:
Visual C# 2005 Express Edition crashes the instant I attempt to view any class in design mode, or just switch the program to design mode (shift-F7). I have tried reinstalling, closing all other non-critical processes, safe mode, restarts and attempting to try design mode on other solutions, all to no effect. The program just comes up with an illegal operation as soon as design mode is supposed to start.
4
3254
by: Academia | last post by:
I create a form Public Class MyTool Inherits MyForm .... which uses:
6
4169
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() Protected mName As String
2
5619
by: programmerx101 | last post by:
Ok, I'm looking for expert advice on this one. I have a database which keeps going into read_only mode. Sometimes it goes into read_only / single user mode. Once it was taken offline completely. This seemingly happens randomly. Out of all of the database I have worked with, this has happened on 3 of them - several times randomly to each. All three of the databases that have exhibited this behaviour have been databases I have written for the...
0
9566
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
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 we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.