Debugging notifications and services on UWP

JohnHardmanJohnHardman GBUniversity mod

Just in case this saves others some time...

On UWP, during development, to assist with debugging after the app has been closed and then re-started from a notification, I originally included the following code to fire up the debugger:

                        if (!System.Diagnostics.Debugger.IsAttached)
                        {
                            System.Diagnostics.Debugger.Launch();
                        }

That dynamically hooked up the debugger as expected. However, subsequently, the following exceptions were reported in the VS Output window:

Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'FormsCommandBarStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'PageControlStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'FormsProgressBarStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'FormsTextBoxStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'AutoSuggestStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'MasterDetailControlStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'TabbedPageStyle.xaml is not a valid absolute URI.'.
Exception thrown at 0x00007FF9287250D8 (KernelBase.dll) in MyApp.UWP.exe: WinRT originate error - 0x80070057 : 'SliderStyle.xaml is not a valid absolute URI.'.

After some investigation, I discovered that if XAML is being used the app needs to be debugged in a container, which presumably VS starts automatically when launching an app the usual way from the VS IDE (e.g. using F5). To get the same result when debugging notifications, services etc., don't use the code shown at the top of this post. Instead open the Properties page for the UWP project, select the Debug pane, and then check the option "Do not launch, but debug my code when it starts". Like magic, debugging of notifications, services etc. works effortlessly.

For ref., see https://docs.microsoft.com/en-us/visualstudio/debugger/start-a-debugging-session-for-a-store-app-in-visual-studio-vb-csharp-cpp-and-xaml?view=vs-2017

Posts

Sign In or Register to comment.