Beantwortet Unclear debugger break due to ListBox

  • Mittwoch, 11. April 2012 08:12
     
     

    Hi, 

    Please help me with a tool generated debugger. I experienced the same debugger break occasionally due to ListBox operation, but I don't know exactly what the problem is, since it occurs without a clear reason. 

    I copy and paste partial code below, 

    the debugger always breaks at "if (Debugger.IsAttached) Debugger.Break();". Second line from the last.

        public partial class App : Windows.UI.Xaml.Application
        {
            private Windows.UI.Xaml.Style ListBoxStyle;
            private bool _contentLoaded;

            [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 4.0.0.0")]
            [System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public void InitializeComponent()
            {
                if (_contentLoaded)
                    return;

                _contentLoaded = true;
    #if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
                UnhandledException += (sender, e) =>
                {
                    if (Debugger.IsAttached) Debugger.Break();
                };
    #endif
            }
        }
    }

    Thanks in advance!

    Jerry

    Hi Min, 

    Is there a better debugging way to trace backward to the source of error? because I had implement ListBox call in many places throughout the code, it will a daunting work to catch all exceptions individually.

    Thank you,

    Jerry

    • Bearbeitet Jerrywu12 Dienstag, 17. April 2012 01:53 extended question
    •  

Alle Antworten

  • Mittwoch, 11. April 2012 08:35
    Moderator
     
     Beantwortet

    Hi Jerry,

    When the code breaks, you can try checking e.Exception for more information about this exception.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Freitag, 20. April 2012 05:40
    Moderator
     
     Beantwortet

    Hi Jerry,

    From your description this is very likely to be a xaml parsing exception, which would crash the application. So I don't think you can log all the exceptions somehow. This have to be done individually.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    • Als Antwort markiert Jerrywu12 Montag, 23. April 2012 03:03
    •  
  • Montag, 23. April 2012 03:03
     
     
    ok, thanks you.

    Jerry

  • Samstag, 28. April 2012 12:46
     
     

    I was having a similar break with a TextBox.  Whenever the textbox took focus either by clicking it or by tabbing into it, I'd get the break.  I even deleted the control and re-added it back into the app with no change.

    The e.Exception info showed

    -  Exception {"Specified cast is not valid."} System.Exception {System.InvalidCastException}

    but didn't give any pointers to the line or method that caused the exception.  The sender is my app name.  I THINK it's a problem with my click event handlers (I have some paths to enable hot spots on an image and set click events on those paths), but don't know for certain.  I'm going to insert a bunch of Try/Catch blocks into the code to see if I can narrow it down.

    Brian

  • Freitag, 11. Mai 2012 02:58
     
     
    I have the same problem,when i use GridView. I change from GridView A to GridView B, it crashs accidentally, the exception shows "Error HRESULT E_FAIL has been returned from a call to a COM component",but i get nothing in e.message. I think this is a xaml problem, but i can not point out where the problem is,since there is no message.
    • Als Antwort vorgeschlagen Carlos A. Pérez Mittwoch, 22. August 2012 15:00
    • Nicht als Antwort vorgeschlagen Carlos A. Pérez Mittwoch, 22. August 2012 15:00
    •  
  • Mittwoch, 22. August 2012 15:08
     
     

    Same here with VS2012 RC. The culprit was an incorrect markup in a GridView, specifically an incorrect CRLF inserted in a DataTemplate section.

    Instead of

    Width="Auto"

    when cutting and pasting, a

    Width="

    Auto"

    was inserted (note the line break). You must carefully inspect your XAML, looking for illegal characters, etc. Since is a Win32 exception, you cannot inspect it as usual, so if you hit "Continue", a dialog box is opened, prompting you to choose a native code debugger.