Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Windows Store application on local machine

I am trying to debug Windows 8 C# Store application with Local Machine debugger. So, I added some incorrect line to MainPage constructor, after InitializeComponent call. I tried the code that causes DivideByZero or NullReferenceException - 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?

like image 789
Alex F Avatar asked Apr 17 '13 12:04

Alex F


People also ask

How do I debug Windows Service on local machine?

In the Options dialog box, choose Debugging, Symbols, select the Microsoft Symbol Servers check box, and then choose the OK button. The Processes dialog box appears. Select the Show processes from all users check box. In the Available Processes section, choose the process for your service, and then choose Attach.

How do I debug a Windows app?

You can use the Windows debuggers (WinDbg, CDB, and NTSD) to debug Windows apps. Use the PLMDebug tool to take control of suspending, resuming, and terminating a Windows app while you are debugging. To debug a managed-code Windows app, load the SOS debugging extension (sos.

How do I debug a deployed application?

To use Visual Studio to debug a deployed application, you must attach to the ASP.NET worker process and make sure that the debugger has access to symbols for the application. You must also locate and open the source files for the application.


3 Answers

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:

enter image description here

like image 144
kimsk Avatar answered Oct 18 '22 03:10

kimsk


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.

like image 21
user1624667 Avatar answered Oct 18 '22 04:10

user1624667


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.

enter image description here

like image 3
Fredrik Avatar answered Oct 18 '22 02:10

Fredrik