I'm trying to save a window's position as a user setting so I can restore it when my app starts up. I add a setting using the designer of this type:
using System.Configuration;
namespace MyApp.Framework
{
[SettingsSerializeAs(SettingsSerializeAs.Xml)]
public class SavedWindowSettings
{
public double Left { get; set; }
public double Top { get; set; }
public SavedWindowSettings()
{
}
public SavedWindowSettings(double left, double top)
{
Left = left;
Top = top;
}
}
}
It compiles, but when I run I get
System.NotImplementedException: 'The method or operation is not implemented.'
but the last thing in the call stack is
PresentationFramework.dll!System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlType(System.Windows.Baml2006.Baml2006SchemaContext.BamlType bamlType, short typeId)
which doesn't help much. I think is has to do with App.config. If I change the type of the setting to string, my App.config has
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
and
<userSettings>
<MyApp.Properties.Settings>
<setting name="MainWindowPlacement" serializeAs="String">
<value />
</setting>
</MyApp.Properties.Settings>
</userSettings>
sections. I tried adding them back in, changing serializeAs
to xml
, with the same exception. What am I missing?