Bug 13664 - IsolatedStorage throws a System.UnauthorizedAccessException
Summary: IsolatedStorage throws a System.UnauthorizedAccessException
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-07-31 15:33 UTC by Pierce Boggan [MSFT]
Modified: 2013-08-21 11:08 UTC (History)
7 users (show)

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 for Bug 13664 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Comment 2 Aaron Bockover [MSFT] 2013-08-07 09:11:20 UTC
The IsolatedStorageFile.GetMachineStoreForXYZ methods throw this exception because the root path for the machine stores resolve to /usr/share/.isolated-storage.

I'm not sure if this is correct, but the concept of machine storage on Mac seems wrong to begin with.

Firstly, machine storage shouldn't use a dot-directory, and the root path should probably be /usr/local/share/mono or /Library/Mono and not /usr/share. /Library/Mono/IsolatedStorage or /usr/local/share/mono/isolated-storage is probably best, and any directories and files created therein should be made world readable/writable I guess (so the same application running under different users can access the files in the same way).
Comment 3 Aaron Bockover [MSFT] 2013-08-07 09:13:25 UTC
Note that similarly on Mac, ~/.config/.isolated-storage is not ideal. It should probably be ~/Library/Mono/IsolatedStorage. I'm not sure why .isolated-storage is a dot directory at all.
Comment 4 Aaron Bockover [MSFT] 2013-08-07 17:41:47 UTC
Conceptually I'm unsure of the "right" thing to do here on Mac. Sharing data across multiple user accounts is a little strange and very technically cumbersome. At best we'd have to instrument the system-Mono installer to set up the right permissions on the Machine Storage directory.

However, the problem can't be fixed for cases where the system-Mono is not used or pre-required (e.g. your application links in and bundles the Mono runtime), since the application itself (run by the user) could not elevate (without lots of extra per-application code) to root/admin privileges to even create and set up the machine storage directory if it were not already set up (and it likely would not be).

I'm thinking maybe for Mac (and probably Linux) we just treat Machine and User storage as the same thing inside the user's home directory.

Apple certainly doesn't want .apps from the store mucking around outside of $HOME or any other further sandboxing (speaking of sandboxing..., effectively hardcoding ~/.config/.isolated-storage [1] is probably a big no-no).

[1] Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData) even resolving to ~/.config is terrible practice on Mac, which is the basis of the root path resolution for IsolatedStorageFile. Other SpecialFolders are similarly bad.
Comment 5 Miguel de Icaza [MSFT] 2013-08-21 11:08:44 UTC
My recommendation is that we fix this as part of our Mobile Profile.

This would ensure that existing apps do not break, and we could add an environment variable or configuration option to go back to the old version.