WPF属性。设置在启动和关闭时引发异常

WPF属性。设置在启动和关闭时引发异常,wpf,application-settings,settings.settings,Wpf,Application Settings,Settings.settings,当我的Wpf应用程序启动时,我在Settings.Designer.cs中收到BindingFailureException [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public global::System.Collections.Specialized.StringCollect

当我的Wpf应用程序启动时,我在Settings.Designer.cs中收到BindingFailureException

[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.
在我的主窗口“代码隐藏”中,我在加载的
窗口上执行以下操作:

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( ));
        }

这也会引发相同的异常。为什么访问
属性.设置时出现异常?

根据我的经验,该异常并不罕见。不寻常的是,在您的情况下,异常(显然)没有得到处理。通常,(在我的经验中也是如此)这个异常会被其他机制默默地捕获和处理


您在VS调试器中运行此命令时不会出现“抛出异常时中断”的情况,是吗?顺便说一句,该设置位于调试->异常…。

是的,我是。这可能就是问题所在。我让内部代码修改了我在同一区域迭代的集合,并认为它与绑定失败异常有关。
try
            {
                //TODO: save prompt
                Properties.Settings.Default.Save( );
            }
            catch (Exception ex)
            {

                Debug.WriteLine(ex.ToString( ));
            }