In my WinForms C# Application I am attempting to save a custom class in a settings file. here is my current code:
public class PanelSaver : ApplicationSettingsBase
{
private DockingStyle ds;
System.Drawing.Point location;
System.Drawing.Size panelSize;
[UserScopedSetting()]
[SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Xml)]
public DockingStyle Style
{
get { return ds; }
set { ds = value; }
}
public System.Drawing.Point Location
{
get { return location; }
set { location = value; }
}
public System.Drawing.Size Size
{
get { return panelSize; }
set { panelSize = value; }
}
}
The DockingStyle variable comes from DevExpress Dockpanels.
Here are the objects being used in the Settings file :
When I attempt to use these variables, by passing them into this function:
private void DockPanelSave(PanelSaver savingPanel, DockPanel realDockingPanel)//
{
try
{
savingPanel.Location = realDockingPanel.Location;
savingPanel.Size = realDockingPanel.Size;
savingPanel.Style = realDockingPanel.Dock;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
throw new NotSupportedException("You may have added a new panel, and may not have added a corresponding " +
"settings variable to hold it in the Settings.settings file");
}
}
I get a null error.
How should I initialize the values in the settings file? I am guessing I need to put in some kind of XML however I don't know the correct steps to take for generating it. Any directions on this or other reasons for my null error would be appreciated