I am developing a Windows Phone 8.1 application where on appbarbutton click, I open a file picker. The app works fine when I run it via visual studio.

But when I run it on the device without being connected to Visual studio,the file picker launches and shows photos library and after I select a photo and click the ok button the screen says resuming for 2-3 secs and the app crashes! 

I have tried setting the Start action of Debug to "Do not launch,but debug my code when it starts" and tried suspend and shutdown option in lifecyle process when the file picker screen is showed. The app calls the Onsuspending method when I do that. But after my selection the app does not call the OnActivated method and shows "resuming..." for a long time until I stop debugging.