Bogdan Bujdea

Windows Platform Developer

Access violation crash on Windows Phone devices

I’m currently working on a Windows Phone 8.1 app and I noticed that the app crashes when I test it on my Lumia 930. The weird thing was that I was getting no exception, the debug session was stopped when I was navigating in the app. I tried to catch unhandled exception but this also failed. I started looking in the debug output, and I noticed the following line:

The program '[3452] MyApp.WindowsPhone.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

I googled around a bit and noticed that other people were having the same issue but in other scenarios. For example, some of them had image manipulation as the cause, others had WebViews(myself included, but this wasn’t the issue in my case), or custom controls. I’ll make your google search easier by enumerating here some of the fixes that I found:

1. Run Visual Studio as administrator

Some people had this issue while building the project, or even when the app was running. It seems that Visual Studio didn’t had enough rights to access some parts of the memory while debugging. For some people it worked running it as administrator, but not for me.

2. Remove WebView

Not something you may want to hear especially if you really need it, but there was/is a bug with the WebView control that was supposed to be fixed in WP 8.1 Update 1. If you need to display a website, you could use the Launcher or you could hope that only a few users will get this crash.

3. Use Dispatcher for navigation

This helped me fix it. Apparently, due to another bug in WP 8.1, you have to use the Dispatcher when you navigate and you have this crash.

 

Here are some of the interesting links I found during my search:

https://social.msdn.microsoft.com/Forums/windowsapps/en-US/854abfa2-5312-4583-92d9-26430c7f5d9c/universal-app-webview-crashing-when-scrolling-windows-phone-81?forum=wpdevelop

https://social.msdn.microsoft.com/Forums/en-US/eb1bd6ed-407a-428b-ba68-eeb68c0ede7d/universal-windows-phone-81-app-crashes-when-scrolling-too-fast-in-webview?forum=wpdevelop

https://social.msdn.microsoft.com/Forums/en-US/6d1a6be3-096e-4090-a4bd-30d1293697b3/windows-phone-81-update-1-access-violation-when-navigating-using-tapped-event?forum=WindowsPhonePreviewSDK

I spent almost one hour searching for some answers so I hope any of these fixes helped you! Happy coding 🙂

, , , , ,