0

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.

背後にある私のMainWindowコードでは、次のことを行っています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ですか?

4

1 に答える 1

2

その例外は、私の経験ではそれほど珍しいことではありません。珍しいのは、あなたの状況では例外が(明らかに)処理されていないことです。通常、(これも私の経験では)その例外は、他のメカニズムによって静かにキャッチされ、処理されます。

万が一、「例外がスローされたときにブレーク」を使用して VS デバッガーでこれを実行していませんか? ちなみに、その設定は Debug -> Exceptions... の下にあります。

于 2010-08-13T20:55:26.470 に答える