Debugging Windows Store application on local machine
Solution 1
It looks like a xaml parsing exception. Have you be able to look at the exception message and see where the error is?
Here is some sample screenshot:
Solution 2
Well when you start Visual Studio you must click on debug and then Options and Settings and then General in Debugging and click on Enable Just My Code.
Solution 3
It can be helpful to enable "Common Language Runtime Exceptions" in "Debug/Windows/Exception Settings" before debugging. Visual studio will now break on the actual error.
Related videos on Youtube
Alex F
Updated on September 15, 2022Comments
-
Alex F over 1 year
I am trying to debug Windows 8 C# Store application with Local Machine debugger. So, I added some incorrect line to
MainPage
constructor, afterInitializeComponent
call. I tried the code that causesDivideByZero
orNullReferenceException
- with the same results.So, I execute "Start Debugging", and debugger breaks here:
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION UnhandledException += (sender, e) => { if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break(); }; #endif
Stack information is not available, it is impossible to detect where is an error (only first-chance exception message in the Output window gives a hint).
I tried to define
DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
in the project preprocessor symbols. This time I got the following strange message: "A debugger is attached to YourProgram.exe but not configured to debug this unhandled exception".Only when specific exception type is checked in the "Exceptions" dialog, and
DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
is defined, I managed to break on the line which caused the error.So, what is the right way to break on the offending line, like is was in traditional desktop applications debugging? If possible, without modifying Exceptions list. And what is exactly the purpose of
DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
constant?-
Alex F@Jack Hughes - it changes something in the debugger behavior, but I am trying to learn, how to debug an error in unknown place. It is impossible to add
Debugger.Launch
before every line in the program...
-
-
NoHarmDan almost 8 yearsThis is the absolutely rightest anwser and should be accepted accordingly.
-
Zdeněk Gromnica almost 8 yearsMissed this. Thanks!
-
A-Sharabiani over 6 yearsThis did not solve my issue, I had
Enable Just My Code
checked but no help.