Sharing violation on path PropertyStore.forms.tmp

JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

I am seeing a huge upswing in reports of this in Insights in the past few days - seems to be mostly on Android, not iOS

the stack trace is

System.IO.FileStream.ctor(System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options)

System.IO.FileStream.ctor(System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous)

System.IO.IsolatedStorage.IsolatedStorageFileStream.ctor(System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf)

System.IO.IsolatedStorage.IsolatedStorageFileStream.ctor(System.String path, FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf)

System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile(System.String path, FileMode mode)

Xamarin.Forms.Platform.Android.Deserializer+<>c__DisplayClass3.<SerializePropertiesAsync>b__2()

System.Threading.Tasks.Task.InnerInvoke()

System.Threading.Tasks.Task.Execute()

has anyone else run across this? Any suggestions on how to handle it?

Posts

  • I am running into this issue when I try to us Application.Current.Properties. If I handle serializing the application state myself (so I never set Application.Current.Properties) I avoid these exceptions.

  • tom-smallstom-smalls GBMember ✭✭

    There's a BugZilla for ths which for some reason has been marked as resolved (even though there are many comments stating/showing that it is not) - https://bugzilla.xamarin.com/show_bug.cgi?id=28709

  • xinmengxinmeng GBMember ✭✭
    edited April 2016

    Is there any document for the Property Dictionary? I also encounter this issue.

    When I rebuild and deployed the app, this issue will be reappear. I found that there are two file in the .config/.isolated_storage :

    PropertyStore.forms
    PropertyStore.forms.tmp 
    

    I think this problem is because the app try to get the data from the PropertyStore.forms.tmp

  • PeterBrachwitzPeterBrachwitz NLMember
    edited February 2017

    Hi,

    I'm getting the following error:

    [ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. ---> System.IO.IOException: Sharing violation on path PropertyStore.forms

    This is the code I'm running:

    protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
            {
                base.OnElementChanged(e);
    
                if (e.OldElement != null || Element == null)
                    return;
    
                try
                {
                    var imageIntent = new Intent();
                    imageIntent.SetType("image/*");
                    imageIntent.SetAction(Intent.ActionGetContent);
                    (Context as MainActivity).StartActivityForResult(
                        Intent.CreateChooser(imageIntent, "Select photo"), 0);
                }
                catch (Exception ex)
                {
                    var what = ex;
                }
            }
    

    In my MainActivity I currently have this, to handle the image selected from the gallery picker:

      protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
            {
                base.OnActivityResult(requestCode, resultCode, data);
    
                if (resultCode == Result.Ok)
                {
                    var app = App.Self;
    
                    var gallery = ((QBaseNavigationPage)app.MainPage).CurrentPage as GalleryPage;
    
                    var path = GetPathToImage(data.Data);
    
                    //using (var file = File.OpenRead(path))
                    //{
                    //    using (var memoryStream = new MemoryStream())
                    //    {
                    //        file.CopyTo(memoryStream);
                    //        file.Close();
                    //        gallery.ReceiveData(memoryStream.ToArray());
                    //    }
                    //}
    
                    var f = File.ReadAllBytes(path);
    
                    gallery.ReceiveData(f);
                }
            }
    
            private string GetPathToImage(Android.Net.Uri uri)
            {
                string doc_id = "";
                using (var c1 = ContentResolver.Query(uri, null, null, null, null))
                {
                    c1.MoveToFirst();
                    var document_id = c1.GetString(0);
                    doc_id = document_id.Substring(document_id.LastIndexOf(":") + 1);
                }
    
                string path = null;
    
                // The projection contains the columns we want to return in our query.
                string selection = Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " =? ";
                using (var cursor = ManagedQuery(Android.Provider.MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] { doc_id }, null))
                {
                    if (cursor == null) return path;
                    var columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
                    cursor.MoveToFirst();
                    path = cursor.GetString(columnIndex);
                }
                return path;
            }
    

    Does anyone have a solution for this? I even tried closing the file explicitly, but to no avail

  • PeterBrachwitzPeterBrachwitz NLMember
    edited February 2017

    Attempt 2, same results:

    protected override void OnResume()
            {
                base.OnResume();
    
                var cursor = MediaStore.Images.Thumbnails.QueryMiniThumbnails(
                                ContentResolver, MediaStore.Images.Thumbnails.ExternalContentUri,
                                ThumbnailKind.MiniKind,
                                null);
    
                App.Thumbnails = new Dictionary<string, byte[]>();
                if (cursor != null)
                {
                    cursor.MoveToFirst();
                    while (cursor.Position != cursor.Count || App.Thumbnails.Count < 10)
                    {
                        var p = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data));
                        var i = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Id));
                        App.Thumbnails.Add(i, File.ReadAllBytes(p));
    
                        cursor.MoveToNext();
                    }
                }
            }
    
  • suringroppersuringropper USMember ✭✭

    Im having the same error:
    Sharing violation on path PropertyStore.forms

    with this call stack:

    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) [0x0026d] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/System.IO/FileStream.cs:249
    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 /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/System.IO/FileStream.cs:149
    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) [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileStream.cs:127
    at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileStream.cs:142
    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 /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs:908
    at (wrapper remoting-invoke-with-check) System.IO.IsolatedStorage.IsolatedStorageFile:OpenFile (string,System.IO.FileMode)
    at Xamarin.Forms.Platform.Android.Deserializer+<>c.b__1_0 () [0x00006] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Deserializer.cs:22
    at System.Threading.Tasks.Task1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
    at Xamarin.Forms.Application+d__68.MoveNext () [0x00046] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Application.cs:240

    i dont even know the origin this exception,
    if any one has any idea ....

  • RaymondKellyRaymondKelly USMember ✭✭✭

    I am also getting the same error. Please someone?

  • JohnHardmanJohnHardman GBUniversity mod

    A new bug has been logged at https://bugzilla.xamarin.com/show_bug.cgi?id=57469 , as https://bugzilla.xamarin.com/show_bug.cgi?id=28709 was marked VERIFIED FIXED.

    Xamarin have already said for 57469 "We will need a preferably minimized reproduction project in order to move forward with this. if we do not receive one after a certain amount of time, we will have to close this issue as not reproducible", so if you are seeing this problem, please update that bug report before it gets closed prematurely.

    The problem originally reported as 28709 was so troublesome that I believe many people stopped using Application.Current.Properties in their own code. I certainly did, changing when it became apparent that there was a lack of understanding of threads/tasks amongst some Xamarin folk at that time. Whilst I'm wary of plugins that are controlled by one person, I switched to using https://github.com/jamesmontemagno/SettingsPlugin . I hope to be able to switch back to Application.Current.Properties at some point, as I would expect that to include support for new platforms (e.g. Tizen) earlier than the Settings plugin. However, enough people are mentioning issues with it still that I have not switched back yet.

  • puthnengputhneng USMember
    edited July 2017

    Hello all dear,

    I got this error from iOS Device when I get data from API. And set data with mvvm binding on listview.

    "System.IO.IOException: Sharing violation on path 433d7f7bbdb9bc90bcfa545b021b9eb8".

    I try to resolve this long time But I still don't understanding why I got like this. Please help me..... this issue.
    Thank you advance.

    Code Behide:

    public void LoadData(LeaveResponseItems leaveItems)
    {
    TotalCount = leaveItems.TotalCount;
    if (leaveItems.Items.Count > 0)
    {
    foreach (var items in leaveItems.Items)
    {

                    var listComplaint = new LeaveItem()
                    {
                        Id = items.Id,
                        ProfileImage = ImageSource.FromUri(new Uri(ConstantImageUrl.ReadImage(items.EmployeeProfilePictureId))),
                        EmployeeName = items.EmployeeName,
                        Date = DateTime.Parse(items.FromDate).ToString("dd/MM/yyyy") + "-" + DateTime.Parse(items.ToDate).ToString("dd/MM/yyyy"),
                        Reason = items.Reason,
                        Period = items.Period > 1 ? items.Period + " "+ App.ApiService.TextTranslate("days") : items.Period +" "+ App.ApiService.TextTranslate("day"),
                        StatusColor = StatusTextBackgroundHelper.BgColorCode(items.StatusState),
                        StatusTitle = StatusTextBackgroundHelper.StatusText(items.StatusState),
                        Al = items.LeaveTypeName,
                        TotalCount = itemCount,
                        RequestedDate = items.RequestDate != null ? App.ApiService.TextTranslate("RequestedOn")+" " + DateTime.Parse(items.RequestDate.ToString()).ToString("dd MMM, yyyy") : App.ApiService.TextTranslate("RequestedOn") +" "+ DateTime.Now.ToString("dd MMM, yyyy"),
                        Comment = items.TotalComment + " " + App.ApiService.TextTranslate("Comment")
                    };
                    LeaveItemSoure.Add(listComplaint);
                    StatusData = true;
                    StatusNoData = false;
                    itemCount += 1;
                }
            }            
            IsEnable = true;
            IsBusy = false;            
        }   
    

    //===========

    public static class ConstantImageUrl
    {
    public static string ReadImage(string id)
    {
    var uid = string.IsNullOrEmpty(id) ? "no-image" : id;
    var url = string.Format(Constant.BaseUrl +"api/FileApp/GetProfileImageSize110?fileName={0}.jpg", uid);
    return url;
    }
    }

  • IntelnegoIntelnego USUniversity ✭✭
  • JohnHardmanJohnHardman GBUniversity mod

    Let's hope so, three years after the initial reports of sharing violations...

Sign In or Register to comment.