Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Method 'System.Collections.Generic.List`1[[CUSTOMTYPE]].Add' not found.
 

Method 'System.Collections.Generic.List`1[[CUSTOMTYPE]].Add' not found.

Trying to add a simple List<T> as a property to a control I have subclassed. Collection editor works fine, I am able to run the app once I populate the list in the designer. However, when I REBUILD the solution the user control containing it bombs with that error in the designer. I have attached my code to see if someone can spot something. Can anyone lend a hand or share a simple example? Thanks!

public class MenuLinkLabel : UltraLabel
{
public MenuLinkLabel()
: base()
{
}

private List<MenuEvent> _menuEvents = new List<MenuEvent>();

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<MenuEvent> MenuEvents
{
get { return _menuEvents; }
set { _menuEvents = value; }
}

[Serializable]
public class MenuEvent
{
public MenuEvent()
{
}

private string _menuText;

public string MenuText
{
get { return _menuText; }
set { _menuText = value; }
}

public override string ToString()
{
if (!string.IsNullOrEmpty(_menuText))
return _menuText;
else
return base.ToString();
}
}
}
LiteWait  Wednesday, August 22, 2007 3:33 PM

Try to remove the 'set' method for the MenuEvents:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

public List<MenuEvent> MenuEvents

{

get { return _menuEvents; }

}

(The designer tries to create a new object of type List<MenuEvent> from the form resources, this cause trouble in the designer.

Eli Gazit  Friday, August 24, 2007 8:36 AM

Try to remove the 'set' method for the MenuEvents:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

public List<MenuEvent> MenuEvents

{

get { return _menuEvents; }

}

(The designer tries to create a new object of type List<MenuEvent> from the form resources, this cause trouble in the designer.

Eli Gazit  Friday, August 24, 2007 8:36 AM

You can use google to search for other answers

Custom Search

More Threads

• VB.NET 2005 *ERROR* DESIGNER LOADER DID NOT PROVIDE ROOT COMPONENT
• Warning in the .net 2005 designer
• Winform for GUI developmwnt
• 'System.OutOfMemoryException' in Windows Forms Designer
• Form inside a form best practice for a .net newby
• Undo option not working.
• Creating see-thru forms?
• How to get point from charindex in textbox
• PERSIST, DAMN YOU! >:(
• Properties bar doesn't work