Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

UWP - file is open error on suspend #14868

Open
curtis91a opened this issue Nov 11, 2021 · 1 comment
Open

UWP - file is open error on suspend #14868

curtis91a opened this issue Nov 11, 2021 · 1 comment

Comments

@curtis91a
Copy link

We are seeing the following issue with our UWP application suspends on some machines

D:\a\1\s\Xamarin.Forms.Platform.UAP\WindowsSerializer.cs at 48, line 4
System.IO.FileLoadException: The process cannot access the file because it is being used by another process. The file is in use. Please close the file before continuing.

Seem like the following line
StorageFile file = await ApplicationData.Current.RoamingFolder.CreateFileAsync(PropertyStoreFile, CreationCollisionOption.ReplaceExisting).DontSync();

is causing the issue.

It seems that it is possible to have 2 of the same applications running at the same time, thus if they both go to sleep the above line should fail. One suggestion is to have a try catch around the CreateFileAsync, if fails with the other process, then open the file and do what is needed.

This has been an issue since xamarin.forms 4.2 but is not showing up a lot with more usage of our system.

@curtis91a curtis91a added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 11, 2021
@jsuarezruiz jsuarezruiz added this to New in Triage via automation Nov 11, 2021
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Dec 13, 2021
@jsuarezruiz jsuarezruiz moved this from New to Needs Estimate in Triage Dec 13, 2021
@curtis91a
Copy link
Author

Here is a sample program to show the error. This just a xamarin.forms sample project that i enabled multi instance.

Deploy the project, then start up 3 or more instances of the program. On the main window you will see the button suspend app. Click that, one or more of the apps will fault and disappear. Hope this helps, i made a private version with the above changes and it seems to resolve the issue for me

MultiInstanceIssue.zip

Triage automation moved this from Needs Estimate to Closed Dec 23, 2021
@curtis91a curtis91a reopened this Dec 23, 2021
Triage automation moved this from Closed to New Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
New
Development

No branches or pull requests

2 participants