In my project I have a custom panel:
[Serializable]
public partial class ButtonPanel : UserControl
{
private List<CompactButton> _compactButtons;
public ButtonPanel()
{
InitializeComponent();
_compactButtons = new List<CompactButton>();
AddButtons();
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(typeof(ButtonPanelXEditor), typeof(UITypeEditor))]
public List<CompactButton> CompactButtons
{
get { return _compactButtons; }
set { _compactButtons = value; }
}
private void AddButtons()
{
CompactButton c = new CompactButton();
c.Enabled = baseButton1.Enabled;
CompactButton c2 = new CompactButton();
c2.Enabled = baseButton2.Enabled;
_compactButtons.Add(c);
_compactButtons.Add(c2);
}
}
On a panel there are two buttons (baseButton1 and baseButton2). The state of these buttons must be saved in the designer. But because the Button class isn't serializable, I have created a custom class to store the most important properties, CompactButton:
[Serializable]
public class CompactButton
{
#region Member variables
private bool _visible;
private bool _enabled;
private string _tooltip;
private string _name;
#endregion
#region Constructor
public CompactButton()
{ }
#endregion
#region Properties
public string Name
{
get { return _name; }
set { _name = value; }
}
public bool Visible
{
get { return _visible; }
set { _visible = value; }
}
public bool Enabled
{
get { return _enabled; }
set { _enabled = value; }
}
public string ToolTipText
{
get { return _tooltip; }
set { _tooltip = value; }
}
#endregion
}
As you can see in the ButtonPanel class, I have a property CompactButtons which returns a list with CompactButtons.
When I add my ButtonPanel in the designer and then build my application I get this error:
Error 1 Could not find a type for a name. The type name was'System.Collections.Generic.List`1[[ButtonPanelX.CompactButton, ButtonPanelX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Line 131, position 5. D:\Projecten\ButtonPanelX\ButtonPanelX\Form1.resx 131 5
What do I have to do to fix this?
ISerializable. - IAbstractControl. - IAbstractControlbecause it isn't serializable. Do you have other suggestions I can try? I have also tried to implementISerializablebut I still get the same error - Martijn