Re: User control with base class cannot be viewed in designer

Tech-Archive recommends: Fix windows errors by optimizing your registry



A further problem was that the base class is generic and the designer just craps out if the base class is generic. I did find a solution for that though, and that is to create a specific class that just inherits from the base generic class and then use this specific class (i.e. no generic parameters) as the base of the control.

"Jack Jackson" <jjackson-nsp@xxxxxxxxxxxxxxxx> wrote in message news:76p9t4t61hf9t27g01nbldmu9408m8619i@xxxxxxxxxx
This is a limitation of the designer. It needs to instantiate the
base class of the class you are designing. Since the base class is
abstract, it can't.

On Thu, 2 Apr 2009 15:30:24 +0200, "....DotNet4Ever...."
<hate.spam@xxxxxxxxxxx> wrote:

I am trying to develop several windows forms user controls for my
application, therefore all of these inherit from
System.Windows.Forms.UserControl as I drop them from the toolbox into the
design surface. I created the user control on the design surface and added
the other winform controls that are grouped into that user control. At this
point it shows fine in the designer. At this point I have

// SomeCompositeControl.cs
public partial class SomeCompositeControl : System.Windows.Forms.UserControl
{
}

// SomeCompositeControl.Designer.cs
public partial class SomeCompositeControl
{
private System.ComponentMode.IContainer components = null;
:
}


Well, In all my winforms and user controls I follow the same pattern. For
that reason I wanted to create an abstract base class for my user control (I
named it MementoUserControlBase):

public abstract class MementoUserControlBase :
System.Windows.Forms.UserControl
{
:
}

and then my user control would be:

// SomeCompositeControl.cs
public partial class SomeCompositeControl : MementoUserControlBase
{
}

// SomeCompositeControl.Designer.cs
public partial class SomeCompositeControl
{
private System.ComponentMode.IContainer components = null;
:
}

The problem is the moment I use the custom base class approach then when I
open my control designer surface rather than being greeted by my carefully
arranged custom user control I get:

"The designer could not be shown for this file because none of the classes
within it can be designed. The
designer inpsected the following classes in the file:
SomeCompositeControl -- the base class 'MementoUserControlBase' could not
be loaded. Ensure the asembly has been referenced and that all projects have
been built"

Both the user control (SomeCompositeControl) and the base class
(MementoUserControlBase) build properly and are in the same project. The
entire project builds without errors.

So, what is wrong here? what sort of weird designer intricacy am I missing?

Emilio

.



Relevant Pages

  • Re: Dynamic loading user controls and saving data?
    ... That is a restriction of the designer. ... instantiate the base class, and it can't if the base class is ... issue I got is when I try to open the user control I got the error: ... public abstract partial class BaseControl: ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: InheritedPropertyDescriptor vs. ReflectedPropertyDescriptor
    ... Class1 derives from some base class. ... Class1.cs, which is the file you double click on to open the designer, ... but Reset changed it to Form1. ... case of the properties that ended with an InheritedPropertyDescriptor. ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: Inherits broken in VB 2.0?
    ... When you create a user control, VS creates a .Designer file that contains ... In there it says that the class inherits ... > "Base class 'System.Windows.Forms.TabControl' specified for class ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Employing a user control to workaround generic designer error
    ... The only reason "UserControl" is mentioned in that thread is that it's the   ... base class of the generic class the questioner is having problems with. ... the generic aspect from the Designer' will bridge this gap. ... can be implemented to allow the use of Generics while avoiding this ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: User control with base class cannot be viewed in designer
    ... This is a limitation of the designer. ... base class of the class you are designing. ... the other winform controls that are grouped into that user control. ... public partial class SomeCompositeControl: System.Windows.Forms.UserControl ...
    (microsoft.public.dotnet.framework.windowsforms)