locked
Issue with debugger (or XAML, I'm not sure which)

    Question

  • I've got a very strange issue at the moment and it is intermittent so I really hate it.

    When I am debugging in VS2012 I often (1 run in 3) get thrown this error in the generated 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

    VS2012 highlights the 'global::System.Diagnostics.Debugger.Break();' section.

    There is no further information to help me work out where this is being thrown from; however if I launch with 'Uninstall and reinstall the package' selected then this issue goes away, so I assume it is part of the startup code.

    That this isn't thrown every time makes me think I have a race condition somewhere, but the obvious candidates (file read/writes) should be managed (I implemented the ASync lock pattern described here: http://blogs.msdn.com/b/pfxteam/archive/2012/02/12/10267069.aspx in the hopes of resolving this issue).

    Are there any advanced debugging tools/tips people might know to help get to the bottom of this - it's going to be something tiny, I'm already resigned to the embarrassment... :)

    Wednesday, March 6, 2013 9:55 PM

Answers

  • Run with the debugger in both managed and native modes (from the Project.Properties... Debug section) and make sure you don't have "Just my code" checked. You may also need to break on the first chance exception here rather than waiting for it to be caught and rethrown. It should give you more information about the exception type so you can switch just it on in the Debug.Exceptions... dialog.

    --Rob

    • Marked as answer by MrChris2000 Saturday, March 9, 2013 12:21 PM
    Wednesday, March 6, 2013 10:06 PM
    Moderator

All replies

  • Run with the debugger in both managed and native modes (from the Project.Properties... Debug section) and make sure you don't have "Just my code" checked. You may also need to break on the first chance exception here rather than waiting for it to be caught and rethrown. It should give you more information about the exception type so you can switch just it on in the Debug.Exceptions... dialog.

    --Rob

    • Marked as answer by MrChris2000 Saturday, March 9, 2013 12:21 PM
    Wednesday, March 6, 2013 10:06 PM
    Moderator
  • Thank you for the advice I believe I have tracked it down now - turning on all the debug made reproducing the issue harder ironically, but when it did repro I was able to get more stack information.

    This:

    The device is not ready. (Exception from HRESULT: 0x80070015)

    and this:

    {System.Runtime.Serialization.SafeSerializationManager}

    Lead me to believe that I was trying to access a resource in the applications storage before the application had been properly registered; I changed the order of some code in App.cs and I've not been able to repro at all since (oh for a good test case though).

    So, thank you; I hope this resolves the issue for my users as well.

    Saturday, March 9, 2013 12:21 PM