LocalSettings breaking on unhandled XAML exception

微笑、不失礼 提交于 2020-01-17 05:06:58

问题


I am having some trouble figuring out why, when I try to define LocalSettings 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:

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

Here is my actual class:

public sealed partial class MainPage : Page
{
    private ApplicationDataContainer _localSettings;

    public MainPage()
    {
        this.InitializeComponent();
        _localSettings = ApplicationData.Current.LocalSettings;
    }
}

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.

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

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

来源:https://stackoverflow.com/questions/40814611/localsettings-breaking-on-unhandled-xaml-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!