When my Wpf app starts up I get a BindingFailureException in Settings.Designer.cs
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Specialized.StringCollection Projects {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["Projects"]));
}
set {
this["Projects"] = value;
}
}
With the following message:
The assembly with display name 'System.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'System.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
In My MainWindow code behind I am doing the following on window_loaded
:
try
{
if (Properties.Settings.Default.Projects==null)
Properties.Settings.Default.Projects=new StringCollection( );
var removalList = new List<string>( );
foreach (string project in Properties.Settings.Default.Projects)
{
if (System.IO.File.Exists(project))
OpenProject(project);
else
{
removalList.Add(project);
}
}
foreach (string missingProject in removalList) //so that we are not removing an item while iterating
{
Properties.Settings.Default.Projects.Remove(missingProject);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString( ));
}
Also in window_closing
try
{
//TODO: save prompt
Properties.Settings.Default.Save( );
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString( ));
}
Which also throws the same exception. Why am I get an exception accessing the Properties.Settings
?