Tag: storage

Windows Phone: Don’t write to the InstalledLocation Folder

Crashes that occur not during development, but only after the application is installed by the Windows Phone store are among the most difficult to troubleshoot. This is one of those bugs.

Windows Phone 8 expanded the file storage APIs to include the StorageFile class support for parity with Windows 8. This class gives you access to ‘special folders’ including the folder where the application is installed. You can get to this folder as follows:

Windows.ApplicationModel.Package package = Windows.ApplicationModel.Package.Current;
Windows.Storage.StorageFolder installedLocation = package.InstalledLocation;

During development you can read and write from this folder, however after installing from the Windows Phone store, any write attempts to this folder will result in a file exception being thrown. Again, this bug will not occur if the app is sideloaded, only when the app is installed from the store. Most likely this is a security precaution to prevent any tampering with the installed files. 

This type of scenario, makes a strong argument for using the beta testing feature of Dev Center that allows you to test the store presentation and installation experience of your app to a specific list of users. By looking at the Dev Center generated crash logs (yes these are generated for beta apps as well as production), you can find the cause of the crash. 

Instead if using the InstalledLocation, you can read and write to the Local Folder. See here for more information.