LocalSettings breaking on unhandled XAML exception
<p>I am having some trouble figuring out why, when I try to define <a href="https://msdn.microsoft.com/library/windows/apps/xaml/windows.storage.applicationdata.localsettings.aspx" rel="nofollow noreferrer">LocalSettings</a> to a field so I can access it from multiple methods, it performs a break during a debug run within App.g.i.cs at the following code:</p>

<pre><code>#if DEBUG &amp;&amp; !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
            UnhandledException += (sender, e) =&gt;
            {
                if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
            };
#endif
</code></pre>

<p>Here is my actual class:</p>

<pre><code>public sealed partial class MainPage : Page
{
    private ApplicationDataContainer _localSettings;

    public MainPage()
    {
        this.InitializeComponent();
        _localSettings = ApplicationData.Current.LocalSettings;
    }
}
</code></pre>

<p>I have tried wrapping it in a try/catch statement, yet that did not catch the exception, so I have no idea what is causing this.</p>

<p>I have also tried directly copying the code from the LocalSettings page linked above, which produces the same problem as my code.</p>

<p>Does anyone know why this is happening, and preferably also where I can find a solution?</p>