Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:35:22+00:00 2026-06-14T05:35:22+00:00

I am trying to have a base Windows Forms form which holds common functionality

  • 0

I am trying to have a base Windows Forms form which holds common functionality and controls – but also holds references to a class which requires a type for its methods. Each form will represent a different type, so I thought that I could do something along the lines of this:

public partial class Base<T> : Form where T : BaseClass
{
    private GenericHandler handler = new GenericHandler();
}

public class BaseClass { }

public class GenericHandler
{
    public void DoSomethingWithInstance<T>(T instance) where T : BaseClass
    {

    }
}

My designer class declaration also mirrors what my form has. Now when I do my second form which represents the type Foo, I can’t access the designer, because I get this error:

The designer could not be shown for this file because none of the
classes within it can be designed. The designer inspected the
following classes in the file: Foo — The base class
‘WindowsFormsApplication1.Base’ could not be loaded. Ensure the
assembly has been referenced and that all projects have been built.

FooClass — The base class ‘WindowsFormsApplication1.BaseClass’
cannot be designed.

public partial class Foo : Base<FooClass>
{
    public Foo()
    {
        InitializeComponent();
    }
}

public class FooClass : BaseClass { }

Why does this happen/what am I doing wrong or are there any other methods to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:35:23+00:00Added an answer on June 14, 2026 at 5:35 am

    When a Windows Form or a user UserControl is loaded in the designer, basically the designer is creating an instance of the base class (that class that your custom form or control directly derives from) and then executes the InitializeComponents() method manually/explicitly through reflection to build up the intended design of your control.

    In your case however it can not create an instance of the base class, because it has a generic parameter. The same thing happens if the base class of your form or your control is abstract or does not have a default constructor. In those cases the designer will also not be able to create an instance of your base class.

    There is a workaround for this using the TypeDescriptionProviderAttribute where you can give the designer a replacement class that it should instantiate instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a C# Windows Forms application which I've attempted to make as
I'm currently designing a custom tab control class which derives from System.Windows.Forms.Control. The problem
I have a simple Windows Forms application which is used to calculate the solutions
I'm trying to use Method.Invoke to call a windows form dialog, have a user
We have a Windows application written in C++, part of which we are trying
I have a base form class that contains a method that returns a DataTable:
Afternoon, I am trying have an HTML file containing a frameset which contains two
I have a cache directory I'm trying to have ignored by git which lives
I'm trying to execute a .bat script in a C# windows service but it
In my C# Windows Forms application, I have a user control that contains other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.