none
User Control Inheritance RRS feed

  • Question

  • I have created a UserControl whos class is declared MustInherit.  It has some MustOverride methods and functions in it, and it has some controls on the base container.  I have built my project and have a DLL.  When I try to create a user control that inherits from this control, I get the dialog message that "No built assemblies contain components to inherit from....".  I can create a new user control, then go to the Designer.vb file and change the inherits clause from UserControl to my base control.  Then, I get errors that I have not yet overridden my MustOverride methods and functions.  This is expected.  I add the overrides for each method and function.  I still cannot open the new control in the designer to add additional controls to it.  I get the error "The designer must create an instance of type 'ucBaseControl.ucBaseControl2' but it cannot because the type is declared as abstract. "  I can compile the project succcessfully.  I can put the new control on a form and it works.  The problem is opening it in the designer.  If I create a second control, have it inherit from the base control I created, then compile the project... I can create a third control, have it inherit from the second control and everything works - except it no loger forces my overrides because they are handled in the second control.

    I am trying to do this to make it easier for our team to develop many user controls based on the base control - and making them go through all the hoops to work around this problem is not acceptable.  Any suggestions would be appreciated.

    I am working with Visual Studio 2008 Visual Basic and we are using the .NET 2.0 libraries for backward compatibility with existing installations.
    RDM
    Wednesday, October 21, 2009 8:56 PM

Answers