1

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:

  1. 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.

  2. 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.

  3. 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

5
  • Well the library don't throw any NotImplementedException. In Visual Studio, if you do a quick CTRL+SHIFT+F of NotImplementedException there's really no results? Nov 19, 2014 at 19:14
  • @Pierre-LucPineault No, the library is clean. Also, it is not a managed exception (the library is part of the source code). If it was managed, I would catch the exception in "UnhandledException" or "UnobservedTaskException" events. I had to catch the exception inside unmanaged code (KERNELBASE.DLL); Nov 19, 2014 at 19:17
  • 1
    So, just to clarify: in the selection changed event handler you're navigating to another page, and that's what's causing the problem? If that's the case, could you try to queue the page navigation to the dispatcher? (That is, invoke it as if the event handler is not invoked in the UI thread.)
    – yasen
    Nov 19, 2014 at 20:56
  • @yasen Thank you for your suggestion! I can't believe I didn't think of the UI thread problem. In Windows Phone 8 I was always using the Dispatcher to execute code on the UI thread. So it works now! The code for 8.1 Dispatcher (for Navigation) is await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if ((!Window.Current.Content as Frame).Navigate(typeof(ItemPage))) { throw new Exception("NavigationFailedExceptionMessage"); } });. Thank you again, @yasen! Nov 19, 2014 at 21:15
  • 1
    I'm glad it fixed your problem! :) I suggested it because I've only encountered KERNELBASE.DLL in errors related to the UI thread access. The strange thing is that in all these cases, the code should've been running on the UI thread anyway, and there should've been no error. Seems like a bug in WP8.1. Edit: it would be nice if you post an answer to this question if you have the time.
    – yasen
    Nov 19, 2014 at 21:27

1 Answer 1

3

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

1
  • Oh God, Thanks. I was having this 0xC0000002 before a navigation, but only happened in Windows Phone 8.1 Preview for Developers, so I took a lot of days to find a solution. Thanks. Jan 25, 2015 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.