Reputation: 103
Good evening,
I am developing a Universal App. After a few random crashes and debugging native code I found out that the native exception is: "Unhandled exception at 0x777E35D7 (KERNELBASE.DLL) in AssemblyName.UniversalApp.WindowsPhone.exe: 0xC0000002: The requested operation is not implemented."
Below is the exception in disassembly. Entry 777E35D7 is missing, this is where the application crashed.
RaiseException:
777E35A0 push {r11,lr}
777E35A4 mov r11,sp
777E35A6 bl __security_push_cookie (777CC868h)
777E35AA sub sp,sp,#0x54
777E35AC and r1,r1,#1
777E35B0 str r1,[sp,#4]
777E35B2 movs r1,#0
777E35B4 str r1,[sp,#8]
777E35B6 ldr r1,RaiseException+50h (777E35F0h)
777E35B8 str r0,[sp]
777E35BA str r1,[sp,#0xC]
777E35BC cbz r3,RaiseException+40h (777E35E0h)
777E35BE cmp r2,#0xF
777E35C0 bhi RaiseException+46h (777E35E6h)
777E35C2 str r2,[sp,#0x10]
777E35C4 lsls r2,r2,#2
777E35C6 add r0,sp,#0x14
777E35C8 mov r1,r3
777E35CA bl memcpy (7781ECC4h)
777E35CE ldr r3,RaiseException+4Ch (777E35ECh)
777E35D0 mov r0,sp
777E35D2 ldr r3,[r3]
777E35D4 blx r3
777E35D6 add sp,sp,#0x54
777E35D8 bl __security_pop_cookie (777CC880h)
777E35DC pop {r11,pc}
777E35E0 movs r3,#0
777E35E2 str r3,[sp,#0x10]
777E35E4 b RaiseException+2Eh (777E35CEh)
777E35E6 movs r2,#0xF
777E35E8 b RaiseException+22h (777E35C2h)
777E35EA __debugbreak
777E35EC ?? ??
777E35EE strb r6,[r0,#0x1E]
777E35F0 adds r5,r5,#0xA1
777E35F2 strb r6,[r7,#0x1D]
What generates this exception:
I use a custom version of this library upgraded to work with Universal Apps: https://github.com/brendankowitz/ZeroProximity.Accordion . I have to mention that the control works fine.
Inside the Accordion Item is a Control Template that contains a ListBox with dynamically binded events (SelectedItemChanged). Randomly, when a ListItem is tapped, the application raises this exception. The code behind the event Navigates the application to another page. I need to specify that the event works without the navigation part and the application doesn't crash.
I also need to specify that the exception occurs only on the device, on all emulators the application works flawlessly. Also, I am a member of "Developer Preview" program, so my Windows Phone version (8.10.14203.306) may influence the application (unfortunatelly, at the moment, I don't have any other devices to test).
My question is: Is there a way to handle this exception, or to find out what exactly is not implemented?
Thank you for your answers!
Regards, Ionut
Upvotes: 1
Views: 3511
Reputation: 103
As Yasen sugested in the comments to my previous post, the Navigation code in Windows Phone 8.1 should run (by default) on the UI thread.
Unfortunately (and I am still trying to find out why) the Navigation code in the ListBoxItem event handler was not running all the time under the UI thread, so a "native code" exception was thrown at random times. Weird enough, the thrown exception did not gave any information about the UI thread (like we received on Windows Phone 8.0 Silverlight), but Yasen pointed out that KERNELBASE.DLL errors are in strong connection with UI thread access exceptions (good to know for future references).
The solution was the use of the Windows Runtime Dispatcher. You can find below the final navigation code that worked.
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
if ((!Window.Current.Content as Frame).Navigate(typeof(ItemPage)))
{
throw new Exception("NavigationFailedExceptionMessage");
}
});
Thank you again, Yasen! You just saved a lot of hours of debugging!
Regards, Ionut
Upvotes: 3