Abstract UserControl problem

Posted on 2007-10-06
Last Modified: 2013-11-26
I am using C# 2.0 VS 2005. Windows Forms.

I have a base UserControl that I have made abstract, as I want to force concrete UserControls that inherit from this BaseUserControl to implement certain abstract methods.

My problem lies in the fact that I can't enter the designer and see the design time view of the UserControls. When Visual Studio attempts to render the UserControl it must automatically attempt to instantiate the base class so I get an error like:

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

How to get around this, or suggestions for this scenario?

Question by:craigdev
    LVL 1

    Author Comment

    no body has any answers on this?
    LVL 9

    Accepted Solution

    Well, it might be one or two but they are workarounds:
    1. Instead of having your methods/UC abstract place some virtual methods there.
    2. Isolate into an Interface the abstract methods. Make your control to derive both
    or better
    3. Use an inner Interface in base, to still make use of the abstract functions calls, i.e.:

    public partial class UserControl1 : UserControl
            public interface IAbstractFunctions
                void MyFunction(string something); // abstract
            public void SometingCallingTheImplementedFunction(IAbstractFunctions objFunctions, string strParameter)


      public partial class UserControl2 : UserControl1, UserControl1.IAbstractFunctions
            private void UserControl2_Load(object sender, EventArgs e)
                base.SometingCallingTheImplementedFunction(this, "that's me The derrived one, calling the implemented MyFunction");    

            public void MyFunction(string something) //implementation of the abstract function

    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now