locked
Can you disable the DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION flag?...

    Question

  • Hi 

    How do I disable DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION, because I'm testing the Application.UnhandledException and it keeps breaking here:

    partial class App : global::Microsoft.Practices.Prism.Mvvm.MvvmAppBase
        {
                ...
                ..
                .
    #if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
                UnhandledException += (sender, e) =>
                {
                    if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
                };
    #endif
            }
        }


    .., but for now I don't want it to stop in the App.g.i.cs file. I'm successfully doing this:

            public App()
            {
                this.InitializeComponent();
                this.RequestedTheme = ApplicationTheme.Light;
                // ensure general app exceptions are handled
                UnhandledException += App_UnhandledException;
            }
    
            private async void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
            {
                NathsarTS.UILogic.Interfaces.IAlertMessageService alertMessageService = ServiceLocator.Current.GetInstance<NathsarTS.UILogic.Interfaces.IAlertMessageService>();
                IResourceLoader resourceLoader = ServiceLocator.Current.GetInstance<IResourceLoader>();
    
                e.Handled = true;
                StringBuilder sMsg = new StringBuilder();
    
                sMsg.Append(resourceLoader.GetString(NathsarTS.Common.Models.CommonNames.UnhandledExceptionMessage)).Append(e.Message).AppendLine();
                sMsg.Append(resourceLoader.GetString(NathsarTS.Common.Models.CommonNames.ExceptionMessage)).Append(e.Exception.Message).AppendLine();
                sMsg.Append(resourceLoader.GetString(NathsarTS.Common.Models.CommonNames.ExceptionInnerException)).Append(e.Exception.InnerException).AppendLine();
                sMsg.Append(resourceLoader.GetString(NathsarTS.Common.Models.CommonNames.ExceptionSource)).Append(e.Exception.Source).AppendLine();
                sMsg.Append(resourceLoader.GetString(NathsarTS.Common.Models.CommonNames.ExceptionStackTrace)).Append(e.Exception.StackTrace).AppendLine();
    
    #if (DEBUG)
                sMsg.Append(resourceLoader.GetString(NathsarTS.Common.Models.CommonNames.ExceptionHelpLink)).Append(e.Exception.HelpLink).AppendLine();
                Debug.WriteLine(sMsg.ToString());
    #endif
    
                await alertMessageService.ShowAsync(sMsg.ToString(), resourceLoader.GetString("UnhandledException"));
            }
    

    Is this possible? 

    Thanks!..


    Code is like a box of chocolates!...

    Friday, October 10, 2014 9:27 PM

Answers

  • DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION is not set by default.

    If it is set, then you're either doing so explicitly or using a package which is setting it.

    You can set whichever conditional compilation symbols you want in Project Properties:

    Project Properties screenshot

    --Rob

    • Marked as answer by VcDeveloper Friday, October 10, 2014 10:59 PM
    Friday, October 10, 2014 10:47 PM
    Owner
  • Hi Rob,

    Looks like its being set by the package of the Prism for Windows Runtime, I don't have it defined in the Project Properties.  I've dropped them a post seeing if this can be done.

    Thanks for your reply!... :)


    Code is like a box of chocolates!...

    • Marked as answer by VcDeveloper Friday, October 10, 2014 10:59 PM
    Friday, October 10, 2014 10:58 PM

All replies

  • DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION is not set by default.

    If it is set, then you're either doing so explicitly or using a package which is setting it.

    You can set whichever conditional compilation symbols you want in Project Properties:

    Project Properties screenshot

    --Rob

    • Marked as answer by VcDeveloper Friday, October 10, 2014 10:59 PM
    Friday, October 10, 2014 10:47 PM
    Owner
  • Hi Rob,

    Looks like its being set by the package of the Prism for Windows Runtime, I don't have it defined in the Project Properties.  I've dropped them a post seeing if this can be done.

    Thanks for your reply!... :)


    Code is like a box of chocolates!...

    • Marked as answer by VcDeveloper Friday, October 10, 2014 10:59 PM
    Friday, October 10, 2014 10:58 PM