Bug 24083 - IsolatedStorageFile.GetUserStoreForApplication causes a crash on iOS 8
Summary: IsolatedStorageFile.GetUserStoreForApplication causes a crash on iOS 8
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.2.0
Hardware: PC Mac OS
: --- normal
Target Milestone: 8.4.0 (iOS 8.1)
Assignee: Bugzilla
URL:
: 24384 ()
Depends on:
Blocks:
 
Reported: 2014-10-27 17:33 UTC by John Miller [MSFT]
Modified: 2014-11-13 12:54 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description John Miller [MSFT] 2014-10-27 17:33:09 UTC
**Overview:**

   IsolatedStorageFile.GetUserStoreForApplication () causes a crash on iOS 8. 

**Steps to Reproduce:**

   Was not able to reproduce locally, but Apple rejected apps crashing with the below Actual Results.

**Actual Results:**

>       at System.IO.Directory.CreateDirectory (string) <0x0008c>
>	at System.Environment.UnixGetFolderPath (System.Environment/SpecialFolder,System.Environment/SpecialFolderOption) <0x001c4>
>	at System.IO.IsolatedStorage.IsolatedStorageFile.GetIsolatedStorageRoot (System.IO.IsolatedStorage.IsolatedStorageScope) <0x00050>
>	at System.IO.IsolatedStorage.IsolatedStorageFile.PostInit () <0x00020>
>	at System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication () <0x00054>


**Expected Results:**

   No crash.

**Build Date & Platform:**

   XI 8.4

**Additional Information:**

   This may be related to the System.Environment.SpecialFolderOption issue related to the path changes noted here: http://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system/
   

@Sebastien, can you confirm this is related?
Comment 1 Sebastien Pouliot 2014-10-27 19:38:06 UTC
Yes. It's unclear why you could not duplicate it... in fact it was surprising we never hit the issue ourselves (that's covered in our test suites).

I'm beginning to suspect this only happens on non-development devices (a bit like the stdout issue for iOS 5.1).

Can you try something for me ? if you still have that test case on any device then reboot* that device and (unconnected to a Mac) try again. Then tell me if the app is working (or crashing like above).

* The reboot should give you a somewhat "clean" device, one that does not have the "dev image" loaded (which will happen if you use Xcode and XS/VS to deploy/start an app).
Comment 2 John Miller [MSFT] 2014-10-28 11:44:16 UTC
@Sebastien,

I tried a few things, but I could not get it to crash. I tried what you suggested with the following code:

> var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
> var filename = Path.Combine (documents, "Write.txt");
> File.WriteAllText(filename, "Write this text into a file");

If there is a better test case I should use, let me know.
Comment 4 Sebastien Pouliot 2014-10-28 14:17:06 UTC
@John no better case. I'm fairly sure the issue is "hidden" on devices in development mode. That would explain why this is not seen in our (and customers) testing.

This was fixed in master / 95bb44d4c5e31e4175cc6a820b2ca70d837d7202 (unreleased)

However the existing workaround [1] does not work for isolated storage, since the path is built inside mscorlib.dll itself.

[1] http://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system/
Comment 15 Sebastien Pouliot 2014-11-10 08:38:28 UTC
*** Bug 24384 has been marked as a duplicate of this bug. ***
Comment 16 softlion 2014-11-11 01:16:21 UTC
Please ship a fix asap. I spoke with 2 other peoples that was having their app rejected for the same reason. But they didn't have any log and didn't understand the root cause.