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 ' 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:
I spent almost one hour searching for some answers so I hope any of these fixes helped you! Happy coding 🙂Follow @thewindev