0
當我的WPF應用程序啓動時我得到了一個Settings.Designer.cs BindingFailureExceptionWPF Properties.Settings上推出拋出異常,並關閉
[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;
}
}
以下消息:
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.
在我主窗口後面的代碼我這樣做對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());
}
另外在window_closing
try
{
//TODO: save prompt
Properties.Settings.Default.Save();
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
其中也會引發相同的異常。爲什麼我得到一個異常訪問Properties.Settings
?
是的,我。這可能是問題所在。 – Maslow 2010-08-13 21:29:28
我的內部代碼修改了我在同一區域迭代的集合,並認爲它與綁定失敗異常有關。 – Maslow 2010-08-13 21:34:24