Bug 28709 - Application.Properties saving crash
Summary: Application.Properties saving crash
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.4.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2015-04-02 16:14 UTC by Marko
Modified: 2017-11-27 07:50 UTC (History)
27 users (show)

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


Attachments
Screenshot showing Xamarin.Insights capture of this exception (176.91 KB, image/png)
2015-06-16 18:31 UTC, John Hardman
Details
SampleProject (185.29 KB, application/zip)
2015-07-13 10:37 UTC, Parmendra Kumar
Details

Description Marko 2015-04-02 16:14:33 UTC
Hi,

using Application.Properties crashes my app from time to time while saving. 


Thanks



[MonoDroid] System.IO.IOException: Sharing violation on path PropertyStore.forms.tmp
[MonoDroid]   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00275] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.IO/FileStream.cs:289 
[MonoDroid]   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous) [0x00000] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.IO/FileStream.cs:190 
[MonoDroid]   at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileStream.cs:129 
[MonoDroid]   at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileStream.cs:144 
[MonoDroid]   at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile (System.String path, FileMode mode) [0x00000] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs:942 
[MonoDroid]   at (wrapper remoting-invoke-with-check) System.IO.IsolatedStorage.IsolatedStorageFile:OpenFile (string,System.IO.FileMode)
[MonoDroid]   at Xamarin.Forms.Platform.Android.Deserializer+<>c__DisplayClass3.<SerializePropertiesAsync>b__2 () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.TaskActionInvoker+ActionInvoke.Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs:71 
[MonoDroid]   at System.Threading.Tasks.Task.InnerInvoke () [0x00031] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:548 
[MonoDroid]   at System.Threading.Tasks.Task.ThreadStart () [0x000d0] in /Users/builder/data/lanes/1353/ac29b2c6/source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:438
Comment 1 Parmendra Kumar 2015-05-06 11:01:56 UTC
@Marko

I have checked this issue and not able to reproduce this issue.
Could you please provide us a sample project, IDE Log? So that we can reproduce it at our end.
you can get IDE Log via: Help->Open Log Directory->IDE.log (chose latest timestamp)
Comment 2 aed 2015-05-29 14:01:12 UTC
Not the OP but I have seen this error a few times.

I don't have the code but here is my recollection of what was causing it:

async void DoSomething()
{
// Change application properties here
// ...
 await Application.Current.SavePropertiesAsync ();
}

Then have a picker P and have it trigger DoSomething OnSelectedIndexChanged.

In my case I was accidentally subscribing the DoSomething event twice to the Picker.

So
P.SelectedIndexChanged += DoSomething;
P.SelectedIndexChanged += DoSomething;

This caused a crash when changing the selected index. Hope it repros for you.
Comment 3 RogerH 2015-06-15 05:13:45 UTC
I have also had this crash.
It was on a Nexus 7 (first edition) with Android 5.1.1 on. Using Xamarin Studio with Xamarin Forms 1.4.3-pre2, compiling on a Mac

I had the same error "Sharing violation on path PropertyStore.forms.tmp" crash.

When the user selects Save in my app's Properties page I commit the Properties to persistent stage using this function

		public static async void Blocking_SaveProperties ()
		{
			await Application.Current.SavePropertiesAsync ();
		}


I have a Button on a Xamarin Form called "Reset Properties"
In the Click Handler I set a bunch of Properties to default values and then call the Blocking_SaveProperties().

It looks like if the user double taps the Button it fires off two Click events, one after the other.
This seems to be the action that triggers the crash.

Perhaps I'm in a state where I've got two overlapping SavePropertiesAsync() being executed.
Perhaps it needs a mutex.
Comment 4 RogerH 2015-06-15 05:14:58 UTC
Also add that I got the crash with current Xamarin Forms 1.4.2.6359 too
Comment 5 John Hardman 2015-06-16 18:31:32 UTC
Created attachment 11633 [details]
Screenshot showing Xamarin.Insights capture of this exception

Screenshot showing Xamarin.Insights capture of this exception.
Comment 6 Jon Goldberger [MSFT] 2015-07-06 21:50:03 UTC
I also tried to replicate this issue given the new descriptions provided but was unable to. I tried both using a button that calls a method on click that executes
await Application.Current.SavePropertiesAsync();
and a picker that subscribes twice to the SelectedIndexChanged event and the handling method calls Application.Current.SavePropertiesAsync();

Clicking the button many times quickly and repeatedly did not cause the noted exception. Also picking an item, and confirming that the handler is called twice, also did not reproduce this exception. 

Can only one provide a build-able test project that reproduces this issue? If so it would be greatly appreciated. 

Note I tested on simulators for KitKat and Lollipop and using Xamarin Forms 1.4.3 current stable release. 

Thanks.
Comment 7 John Hardman 2015-07-13 07:24:35 UTC
Here's a stack trace from my iPad, followed by code that reproduces the issue:

Sharing violation on path PropertyStore.forms.tmp (System.IO.IOException)
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00351] in /Users/builder/data/lanes/1503/6481535e/source/mono/mcs/class/corlib/System.IO/FileStream.cs:290 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/mono/mcs/class/corlib/System.IO/FileStream.cs:157 
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage
FileStream.cs:127 
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileStream.cs:142 
  at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile (System.String path, FileMode mode) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs:908 
  at Xamarin.Forms.Platform.iOS.Deserializer+<>c__DisplayClass3.<SerializePropertiesAsync>b__2 () [0x00008] in <filename unknown>:0 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00012] in /Users/builder/data/lanes/1503/6481535e/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2901 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/1503/6481535e/source/mono/external/referencesource/mscorlib/system/threading/Task
s/Task.cs:2523 


Just hook the following up to a button and press the button.

        void OnButtonClicked(object sender, EventArgs e)
        {
            int j = -1;
            try
            {
                int seed = 13;
                while (++j < 1000)
                {
                    seed = ((seed * 257) + 41) % 65536;
                    int i = seed % 20;

                    int previousClickTotal = -1;
                    if (Application.Current.Properties.ContainsKey("PreviousClickTotal" + i.ToString()))
                        previousClickTotal = (int)(Application.Current.Properties["PreviousClickTotal" + i.ToString()]);

                    string clickTotal = "0";
                    if (Application.Current.Properties.ContainsKey("ClickTotal" + i.ToString()))
                        clickTotal = (string)Application.Current.Properties["ClickTotal" + i.ToString()];

                    double nextClickTotal = 1.0;
                    if (Application.Current.Properties.ContainsKey("NextClickTotal" + i.ToString()))
                        nextClickTotal = (double)(Application.Current.Properties["NextClickTotal" + i.ToString()]);

                    Application.Current.Properties["PreviousClickTotal" + i.ToString()] = ++previousClickTotal;
                    Application.Current.Properties["ClickTotal" + i.ToString()] = previousClickTotal.ToString();
                    Application.Current.Properties["NextClickTotal" + i.ToString()] = ++nextClickTotal;

                    SaveAllProperties();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("j=" + j);
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }

        async void SaveAllProperties()
        {
            await Application.Current.SavePropertiesAsync();
        }
Comment 8 Parmendra Kumar 2015-07-13 10:33:13 UTC
I have checked this issue with given sample code in comment #7 and getting same exception mentioned in comment #7.

Screencast: http://www.screencast.com/t/nw6hqAi4

ApplicationOutput: https://gist.github.com/Parmendrak/1a85c5de25c25a8fdb51
Ide Log: https://gist.githubusercontent.com/Parmendrak/2958456ec30c2635b1a9/raw/IDELog
Simulator Log: https://gist.github.com/Parmendrak/614df8286ef55515e060

Environment info:

Xamarin.Forms 1.4.3.6376
Xamarin Studio: 5.9.4 (build 5)
Mono 4.0.2 ((detached/c99aa0c)
GTK+ 2.24.23 (Raleigh theme)
Xcode 6.2 (6776)
Xamarin.iOS : 8.10.3.2 (Enterprise Edition)
Xamarin.Android : 5.1.4.16 (Enterprise Edition)
Mac OS X 10.9.4
Comment 9 Parmendra Kumar 2015-07-13 10:37:38 UTC
Created attachment 12000 [details]
SampleProject
Comment 10 Rui Marinho 2015-08-21 13:48:10 UTC
Hello, the issue i m seeing seems to be related with the sample and the use of the async/await the SavePropertiesAsync. 

If you change the code to:

>await SaveAllProperties();

>Task SaveAllProperties()
>{
>    return Application.Current.SavePropertiesAsync();
>}


it works as expected.
Comment 11 RogerH 2015-08-25 04:47:20 UTC
Can I clarify - has this been resolved by a fix in Xamarin Forms or just by telling us to change our code.
Comment 12 Rui Marinho 2015-08-25 06:38:45 UTC
Hi Roger, just change the code, there was no fixes, since it seems to work ok.
Comment 13 John Hardman 2015-08-25 08:59:49 UTC
Not entirely convinced. The sample code provided was just some code that provided a repeatable way of getting the error to occur. It is not how my real code is written, but the error only shows up intermittently in the real code, so not much use as a demonstration of the problem.

I suspect that there should be a TryLock inside code used within SavePropertiesAsync.
Comment 14 RogerH 2015-08-25 09:06:24 UTC
I agree with John Hardman. I think a Lock is needed and it was using a Lock() to prevent SavePropertiesAsync() being called while another SavePropertiesAsync() was still being executed that solved the problems for me.

So really the workaround for the XF bug is something like this

        async void SaveAllProperties()
        {

            await Application.Current.SavePropertiesAsync();
        }
Comment 15 RogerH 2015-08-25 09:08:04 UTC
I agree with John Hardman. I think a Lock is needed and it was using a Lock() to prevent SavePropertiesAsync() being called while another SavePropertiesAsync() was still being executed that solved the problems for me.

So really the workaround for the XF bug is something like this

        Object save_properties_lock = new Object();
        async void SaveAllProperties()
        {
            lock(save_properties_lock() {
                await Application.Current.SavePropertiesAsync();
            }
        }

This is more or less how I coded it in my Android and iOS app.

Would be nice to have this fixed in Xamarin Forms.
Comment 16 Rui Marinho 2015-08-25 10:41:35 UTC
The sample didn't use async/await correctly, if you await the SavePropertiesAsync you shouldn't need the lock. This is the common scenario for most XF users.
You could also do the lock yourself like expressed by RogerH in comment15.

That said, we appreciate your feedback and we will discuss internally if we need changes in this particular feature. 

Warm Regards
Xamarin Forms Team
Comment 18 John Hardman 2015-08-26 17:50:25 UTC
Just to confirm, I have put the "correct" code (using async/await, but without an explicit lock) back into my app and have seen the exceptions reported in this bug appear again in Xamarin.Insights.

Whether it makes any difference I do not know, but I use this in App.OnSleep(). Can you see any particular issue with doing this?
Comment 19 Richard Edwards 2015-09-16 08:48:22 UTC
I'm also having this same issue. If I comment Application.Current.SavePropertiesAsync() in my code the problem goes away. I've even tried awaiting it and the same problem occurs.

I tried to use the code in a previous reply with the lock but I'm getting an error with awaiting inside a lock so I'm not sure how anyone has even used that.

If I hit the home key for iOS and put the app into the background the settings are saved fine, no sharing violation at all.

I think I might have to go and try out a settings plugin or something else as this seems to be buggy.

Anyone else had any success with this?

I'm using all of the current Xamarin bits.
Comment 20 RogerH 2015-09-16 09:13:22 UTC
Hi Richard
The code I used was like this
        Object save_properties_lock = new Object();
        async void SaveAllProperties()
        {
            lock(save_properties_lock() {
                await Application.Current.SavePropertiesAsync();
            }
        }

This was because I had multiple places in one class that called SavePropertiesAsync().

My issue was actually users tapping twice on a "Save Settings" button which caused overlapping SaveProperties()

Have you tried a static method with a lock to save the properties. I used that so all the settings were written in one place (and with one lock)
Comment 21 Richard Edwards 2015-09-16 09:38:29 UTC
Hi Roger,

If I add that code I get an error:

The 'await' operator cannot be used in the body of a lock statement.
Comment 22 Kent Green [MSFT] 2015-10-07 18:24:02 UTC
Possibly related:

> "Async void is a 'fire-and-forget' mechanism: the caller is unable to know when an async void has finished, and the caller is unable to catch any exceptions from it. The only case where this kind of fire-and-forget is appropriate is in top-level event-handlers. Every other async method in your code should return 'async Task'."

- https://channel9.msdn.com/Series/Three-Essential-Tips-for-Async/Tip-1-Async-void-is-for-top-level-event-handlers-only
Comment 23 Ian Geoghegan 2015-10-13 19:14:59 UTC
I don't know how this got resolved as answered. Richard Edwards rightly points out that an await can't exist in a lock and regardless, the SavePropertiesAsync() method should handle repeated calls by clients.
Comment 24 Ian Geoghegan 2015-10-13 19:15:52 UTC
I should add - this issue still exists in 1.5.
Comment 25 Richard Edwards 2015-10-13 19:21:00 UTC
I haven't been getting the error any more. I set up a SettingsService like so, in case I needed to swap it out for something else. Probably should implement an interface but this works for me at this point. Running Xamarin.Forms 1.5.0.6447 right now.

	public class SettingsService
	{
		public SettingsService ()
		{
		}
		public static async Task SaveAllSettings()
		{
			await Application.Current.SavePropertiesAsync();
		}

		public static void Set(string key, object value){
			Application.Current.Properties[key] = value;
		}

		public static T Get<T>(string key, T @default){
			if (Application.Current.Properties.ContainsKey (key)) {
				return (T) Application.Current.Properties[key];
			}
			return @default;
		}

		public static void Remove(string key) {
			if (Application.Current.Properties.ContainsKey (key)) {
				Application.Current.Properties.Remove(key);
			}
		}
	}
Comment 27 Brian 2015-10-16 10:52:17 UTC
I had this come up today.

I was able to resolve the issue by making sure I called the code on the UI thread...

 Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
{
 await Settings.Save();
}
Comment 28 Ian Geoghegan 2015-10-16 13:41:56 UTC
Brian, what is "Settings" here? Do you mean App.Current.SavePropertiesAsync() or do you mean a call to Richard's wrapper? Either way, I can't any of this to work consistently.
Comment 29 John Hardman 2015-10-17 08:08:47 UTC
Same here. I'm not sure what Settings is, so tried the following without success:

            Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
            {
                await Application.Current.SavePropertiesAsync();
            });

This still throws an exception.

I remain incredulous that this is marked as RESOLVED ANSWERED.
Comment 30 François M 2015-11-30 08:46:41 UTC
I agree this not resolved.
Moreover, what's the point of an aynschronous method if it needs to be awaited to work? Just make it syncrhonous then.
Comment 31 François M 2015-11-30 09:26:41 UTC
Let me add that
1) await is not the solution as several awaited calls coming from different places can still occur at the same time
2) you changed Something in XF lately as I never had this error before while it now appears on lines of codes written a long time ago.
Comment 32 Phillip Wells 2016-02-03 04:32:14 UTC
I've been fighting this for several days now!!  I know someone at Xamarin is smart enough to fix this!!

The lack of response has me thinking about NativeScript!!!!
Comment 34 aed 2016-02-11 19:20:02 UTC
This still repros for me. I have locks and awaits which got rid of some occurrences, but now the program crashes if it tries to write any information on start-up. 

In my case I write out the number of times the app was opened on start-up.
Comment 35 Rui Marinho 2016-02-12 03:23:17 UTC
Hi can you please provide a repo so we can take a look? 

Thanks.
Comment 36 John Hardman 2016-02-12 09:24:05 UTC
Hi Rui. Unless Comment 34 relates to a particular scenario that repros every time, remember that the bug described in this thread is timing related. Whether task/thread related, it does not happen every time, but it happens a lot, so when you look at a repro sample, if it doesn't fail first time, please try it multiple times. This bug has been here for 10 months - despite somebody having marked it as RESOLVED ANSWERED, it clearly is still present and the status needs changing to reflect this.

The code in comment 7 (provided 7 months ago) reliably triggered the problem. That the code in comment 7 was intentionally badly behaved to make it very likely the problem would show up seems to have been interpreted incorrectly as user error. It was not. It was written that way on purpose so that Xamarin could see what is an intermittent problem and then try to trace it. That's the problem with timing/task/thread related bugs - as they don't happen every time, repro samples have to do bad stuff to make it likely that the problem will show up when checked.
Comment 37 Rui Marinho 2016-02-12 19:32:44 UTC
Hi everyone, after some talks with the rest of the team we think we know what's going on, we are reopening and investigating again a possible fix that will be more regarding  queuing that on locking.. 
We do think we got the root cause for the problem, it seems this only happens if  the user is saving at the same time Xamarin.Forms is also saving, like for example when the app pauses. 

Will keep you guys posted, if you having this error please email me at rui at xamarin.com so i can maybe provide a build to see if it fixes the problem.
Comment 38 Rui Marinho 2016-02-15 16:12:26 UTC
Hi, we have have a possible fix ready and will be happy to distribute to anyone that's willing to test it out to see if it fixes the problem. Please reach me via email.
Comment 39 Phillip Wells 2016-03-01 00:10:04 UTC
Do we need to wait on Microsoft to fix this one?
Comment 40 Phillip Wells 2016-03-01 00:10:14 UTC
Do we need to wait on Microsoft to fix this one?
Comment 41 Rui Marinho 2016-03-01 19:04:20 UTC
Hey Phillip we have a fix ready if you want to try it please email me. rui at xamarin.com
Comment 42 Phillip Wells 2016-03-19 23:00:58 UTC
Rui, has anyone had any luck with the fix? I'm going to have to talk with accounting about not charging me anymore until basic crap like this works!!!
Comment 43 Brendan Zagaeski (Xamarin Support) 2016-03-20 21:23:52 UTC
Dear Mr. Wells,


If you haven't yet contacted Rui via email (as per Comment 41), or if you have contacted him and not heard back yet, please free to send a message to contact@xamarin.com for further assistance with getting a candidate build that includes the candidate fix mentioned in Comment 41. Be sure to include a link to this comment (Bug 28709, Comment 43) in your email so that the support team will know the context of the message to contact@xamarin.com (especially if by chance you might be using an Indie license or lower that usually isn't eligible for email support). Thanks!


Best,
Brendan
Xamarin Customer Support
Comment 44 Jason Smith [MSFT] 2016-03-20 23:24:05 UTC
This should be fixed in 2.2.0-pre1
Comment 45 Parmendra Kumar 2016-04-06 11:46:28 UTC
I have checked this issue with xamarin.forms 2.2.0-pre1 and its working fine with using attached sample project in comment #9.

Screencast: http://www.screencast.com/t/cLV2yaG6fg

Hence I am closing this issue.

Please feel free to reopen this issue If you still facing sample issue.

Thanks.
Comment 46 Artur Malendowicz 2016-11-28 08:36:25 UTC
This bug has regression. It is again crashing on for example Sony Xperia Z5 Compact.
Comment 47 Hines Vaughan III 2017-06-12 15:58:17 UTC
Any update on this? I am seeing this exception in HockeyApp logs. Also this bug was never set to RESOLVED FIXED so did it ever get released?
Comment 48 John Hardman 2017-06-13 09:23:55 UTC
@"Hines Vaughan III" - I tested this yesterday using the badly behaved code from earlier in the bug history. I tested on both UWP and Android, and did not see the problem occur on either.

If you are still seeing this problem, can you let Xamarin have a repro-sample and specify what platforms you see the problem on and which Xamarin.Forms version you are using.

You might need to open a new bug report, as you probably won't be able to change the status on this one.
Comment 49 Marek Mierzwa 2017-06-14 06:34:47 UTC
I'm seeing this bug in my production code (Forms 2.3.4.247):

Package: xxx
Version Code: 1705181035
Version Name: 1.2.1
Android: 5.1.1
Android Build: LMY47V.J105YDVU0AQC1
Manufacturer: samsung
Model: SM-J105Y
Thread: main-1
CrashReporter Key: 5B5B2FF7-106A-8DB2-3840-7A889DB590CB039F9399
Start Date: Tue Jun 13 21:42:01 GMT+03:00 2017
Date: Tue Jun 13 21:42:29 GMT+03:00 2017
Format: Xamarin

Xamarin caused by: android.runtime.JavaProxyThrowable: System.IO.IOException: Sharing violation on path PropertyStore.forms.tmp
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x001f1] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x0000a] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at (wrapper remoting-invoke-with-check) System.IO.IsolatedStorage.IsolatedStorageFileStream:.ctor (string,System.IO.FileMode,System.IO.IsolatedStorage.IsolatedStorageFile)
  at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile (System.String path, System.IO.FileMode mode) [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at (wrapper remoting-invoke-with-check) System.IO.IsolatedStorage.IsolatedStorageFile:OpenFile (string,System.IO.FileMode)
  at Xamarin.Forms.Platform.Android.Deserializer+<>c__DisplayClass2_0.<SerializePropertiesAsync>b__0 () [0x00008] in <1481f85a917c4f2b882ea161e9bc082f>:0 
  at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at Xamarin.Forms.Application+<SetPropertiesAsync>d__74.MoveNext () [0x0009f] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at Xamarin.Forms.Application+<SavePropertiesAsync>d__51.MoveNext () [0x0007f] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity+<OnStateChanged>d__44.MoveNext () [0x000f8] in <1481f85a917c4f2b882ea161e9bc082f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <1061b4e4931f4aff8dfecaa9c69ba741>:0 
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <0d12b3df98074afea1b52c95a3f493c4>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <0d12b3df98074afea1b52c95a3f493c4>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <0d12b3df98074afea1b52c95a3f493c4>:0 
  at (wrapper dynamic-method) System.Object:9c846fbb-5d8d-42d8-8c85-6d259815e6a5 (intptr,intptr)
	at mono.java.lang.RunnableImplementor.n_run(Native Method)
	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:145)
	at android.app.ActivityThread.main(ActivityThread.java:6934)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Comment 50 Marek Mierzwa 2017-06-14 07:11:46 UTC
As @'John Hardman' suggested I opened a new bug for this - https://bugzilla.xamarin.com/show_bug.cgi?id=57469
Comment 51 Luiz Arantes Sa 2017-10-03 19:47:13 UTC
This is still not resolved.

Xamarin Exception Stack:
System.IO.IOException: Sharing violation on path PropertyStore.forms.tmp
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x001f1] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x0000a] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at (wrapper remoting-invoke-with-check) System.IO.IsolatedStorage.IsolatedStorageFileStream:.ctor (string,System.IO.FileMode,System.IO.IsolatedStorage.IsolatedStorageFile)
  at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile (System.String path, System.IO.FileMode mode) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at (wrapper remoting-invoke-with-check) System.IO.IsolatedStorage.IsolatedStorageFile:OpenFile (string,System.IO.FileMode)
  at Xamarin.Forms.Platform.Android.Deserializer+<>c__DisplayClass2_0.<SerializePropertiesAsync>b__0 () [0x00008] in <1481f85a917c4f2b882ea161e9bc082f>:0
  at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at Xamarin.Forms.Application+<SetPropertiesAsync>d__74.MoveNext () [0x0009f] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at Xamarin.Forms.Application+<SavePropertiesAsync>d__51.MoveNext () [0x0007f] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity+<OnStateChanged>d__44.MoveNext () [0x000f8] in <1481f85a917c4f2b882ea161e9bc082f>:0
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <d278c06ad5684d6882c743a94a93ebc2>:0
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0
  at (wrapper dynamic-method) System.Object:bf4e8506-ef73-4cd9-bc08-cf01e3533115 (intptr,intptr)
Comment 52 Damir Beylkhanov 2017-11-23 11:33:49 UTC
Should be already fixed on 2.5, no?

Note You need to log in before you can comment on or make changes to this bug.