473,699 Members | 2,745 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 1533
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 Sjgren [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
5877
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
2101
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
2761
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
2189
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
1701
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
1101
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
3252
by: Academia | last post by:
I create a form Public Class MyTool Inherits MyForm .... which uses:
6
4168
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
5613
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
8705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8623
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8941
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6549
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
5881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4390
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...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
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
2362
muto222
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.