-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IsolatedStorageFile.GetUserStoreForApplication path changes between Xamarin.iOS and .NET 6 builds on iOS #74642
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsDescriptionThe path of a file created by IsolatedStorageFile.GetUserStoreForApplication() changes between Xamarin.iOS and dotnet 6, and also changes between different builds of the application under dotnet 6. For example, the following code:
results in the file being written to various locations in the iOS device file system depending on the build of the application:
In Xamarin.iOS the path of the file was consistent across builds of the app. Reproduction StepsBuild the code below on Xamarin.iOS and execute on an iOS device.
Expected behaviorThe settings.txt file should be created in the same file system location (path) for every version of the built application. Actual behaviorThe settings.txt file is created in a different file system location (path) for every version of the built application on dotnet 6 Regression?Yes, this is a regression. The file system path for IsolatedStorageFile was consistent in .NET Framework applications I've built over the past decade with many different versions of .NET and Xamarin.iOS. Known WorkaroundsI don't know of any workaround using the dotnet Configurationdotnet 6 This issue is specific to dotnet 6 on iOS Other informationNo response
|
The legacy IsolatedStorageFile.GetUserStoreForApplication() folder on Xamarin.iOS is:
As a workaround, this path can be recreated manually in .NET 6 using Legacy files can then be accessed using |
This is broken in the same way on Android. The legacy IsolatedStorageFile.GetUserStoreForApplication() folder on Xamarin.Android is:
As a workaround, this legacy path can be recreated manually in .NET 6 using Legacy files can then be accessed using |
Tagging subscribers to 'os-ios': @steveisok, @akoeplinger Issue DetailsDescriptionThe path of a file created by IsolatedStorageFile.GetUserStoreForApplication() changes between Xamarin.iOS and .NET 6, and also changes between different builds of the application under .NET 6. This makes IsolatedStorageFile unusable in .NET 6 since an updated build cannot open a file created by a previous build. Each time the build is updated, all of the files previously created on behalf of the user are effectively gone. For example, the following code:
results in the file being written to various locations in the iOS device file system depending on the build of the application:
In Xamarin.iOS the path of the file was consistent across builds of the app. Reproduction StepsBuild the code below on Xamarin.iOS and execute on an iOS device.
Expected behaviorThe settings.txt file should be created in the same file system location (path) for every version of the built application. Actual behaviorThe settings.txt file is created in a different file system location (path) for every version of the built application on dotnet 6 Regression?Yes, this is a regression. The file system path for IsolatedStorageFile was consistent in .NET Framework applications I've built over the past decade with many different versions of .NET and Xamarin.iOS. Known WorkaroundsI don't know of any workaround using the .NET 6 Configuration.NET 6 This issue is specific to .NET 6 on iOS Other informationNo response
|
Hi @dtaylorus,
I'm trying on Android device, running on Debug mode using Visual Studio 2022 for Mac v17.4 Preview. (For release mode unfortunately I still have exception while running, working on it) |
Probably the simplest thing to do is create the same project for legacy Xamarin.Android (not .NET 6) and see that the path is completely different and doesn't even contain the 'Url' part of the path that is new in .NET 6 for Android. This means that projects that were released on legacy Xamarin.Android will lose access to files created with IsolatedStorageFile after upgrading the project to .NET 6. If this backward compatibility issue is fixed, the part of this issue about the path constantly changing will be irrelevant anyway since there won't be a Url part of the path that can change. Also note that I found the behavior about the path changing on .NET 6 for iOS, not Android. I only verified that the backward compatibility issue exists on Android (where the path changes between Xamarin.Android and .NET 6 for Android). I have not tested for the changing path between builds on Android being the same as on iOS. Hope that makes sense. Thanks for looking into this issue |
To answer your specific questions, I'm building on Visual Studio 2022 for Windows. My Android builds are local (SDK version 33) and my iOS builds are via a remote connection to a MacOS machine. I've tested in both debug and release builds and the results appear to be the same. My project is a released app that is way too big to share. I encountered this problem when I was forced to upgrade the project to .NET 6 because of some dependencies. I was able to work around the issue by replacing all references to IsolatedStorageFile with direct use of System.IO.File. |
* #74642 changed isolated storage path for mobile platforms
Fantastic. Thanks all! |
* #74642 changed isolatedstorage path * #74642 Refactored and changed root only for mobile * #74642 minor changes * #74642 removed redundunt code * #74642 rename IsolatedStorageDirectoryName * #74642 change also in comments * #74642 changed IsolatedStorageDirectoryName for only mobile * #74642 done minor changes * #74642 made IsolatedStorageDirectoryName const * #74642 removed whitespaces * #74642 fix csproj for linux Co-authored-by: Meri Khamoyan <[email protected]>
Description
The path of a file created by IsolatedStorageFile.GetUserStoreForApplication() changes between Xamarin.iOS and .NET 6, and also changes between different builds of the application under .NET 6.
This makes IsolatedStorageFile unusable in .NET 6 since an updated build cannot open a file created by a previous build. Each time the build is updated, all of the files previously created on behalf of the user are effectively gone.
For example, the following code:
results in the file being written to various locations in the iOS device file system depending on the build of the application:
In Xamarin.iOS the path of the file was consistent across builds of the app.
Reproduction Steps
Build the code below on Xamarin.iOS and execute on an iOS device.
Migrate the app to dotnet 6, rebuild and execute on the same iOS device.
Note that the file is created in a different file system location on the device.
Clean and rebuild the dotnet 6 app and execute on the same iOS device.
Note that the file is created in yet another file system location on the device.
Expected behavior
The settings.txt file should be created in the same file system location (path) for every version of the built application.
Actual behavior
The settings.txt file is created in a different file system location (path) for every version of the built application on dotnet 6
Regression?
Yes, this is a regression. The file system path for IsolatedStorageFile was consistent in .NET Framework applications I've built over the past decade with many different versions of .NET and Xamarin.iOS.
Known Workarounds
I don't know of any workaround using the .NET 6
IsolatedStorageFile
API. Applications would have to use some other file system API and maybeEnvironment.GetFolderPath(SpecialFolder folder)
.Configuration
.NET 6
iOS
ARM64
This issue is specific to .NET 6 on iOS
Other information
No response
The text was updated successfully, but these errors were encountered: