“Could not find type” error loading a form in the Designer

Posted by Vaccano on Stack Overflow See other posts from Stack Overflow or by Vaccano
Published on 2010-01-04T18:29:41Z Indexed on 2010/04/10 18:03 UTC
Read the original article Hit count: 361

Filed under:
|
|
|
|

This is the exact same question as this one: “Could not find type” error loading a form in the Designer

Before anyone goes closing my question please read that one. You will realize that it did not get a real answer. I hope to get a full answer (rather than a workaround) from this question.

When I create a class that descends from Control and uses generics, that class fails to load in the designer.

Here is and example:

class OwnerDrawnListBox<T> : System.Windows.Forms.Control
{

    private readonly List<T> _items;

    // Other list box private stuff here

    public OwnerDrawnListBox()
    {
        _items = new List<T>();
    }

    // More List box code
}

I then use this in my designer:

private OwnerDrawnListBox<Bag> lstAvailable;

private void InitializeComponent()
{
    // Used to be System.Windows.Forms.ListBox();
    this.lstAvailable = new ARUP.ScanTrack.Mobile.OwnerDrawnListBox<Bag>(); 
    // Other items
}

If the generic class is subclassed (to a non-generic) then the referenced question says that it works fine (ie if I made Class BagOwnerDrawListBox: OwnerDrawnListBox<Bag>).

What I want to know is there a way to "fix" this so that the generic item is accepted by the designer?

Side Note: I am using the Compact Framework.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET