Sharing violation on Android using Xamarin Forms
See original GitHub issueHi,
Have randomly been getting the following error:
Unable to retrieve image data
System.IO.IOException: Sharing violation on path /data/user/0/<project>/cache/ImageService/7b8116362b9408c1d5e7437479980e90
Unfortunately I’m unable to provide an example to replicate the issue as it happens randomly. The app I’m using your awesome package with does a lot of image downloading on app load so perhaps there’s too much happening at once?
Here’s the full stack trace:
System.IO.IOException: Sharing violation on path /data/user/0/<project>/cache/ImageService/7b8116362b9408c1d5e7437479980e90
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x0026d] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.IO/FileStream.cs:257
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/2185/53fce373/source/mono/mcs/class/corlib/System.IO/FileStream.cs:157
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access) [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.IO/FileStream.cs:92
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess)
at FFImageLoading.IO.FileStore.GetOutputStream (System.String path) [0x00000] in <filename unknown>:0
at FFImageLoading.Cache.DiskCache+<AddOrUpdateAsync>c__async0.MoveNext () [0x00072] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:477
at FFImageLoading.Cache.DownloadCache+<DownloadAndCacheAsync>c__async2.MoveNext () [0x003b6] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[System.IO.MemoryStream].GetResult () [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:580
at FFImageLoading.Cache.DownloadCache+<GetStreamAsync>c__async1.MoveNext () [0x00102] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[FFImageLoading.Cache.CacheStream].GetResult () [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:580
at FFImageLoading.Work.StreamResolver.UrlStreamResolver+<GetStream>c__async0.MoveNext () [0x0008f] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[FFImageLoading.Work.WithLoadingResult`1[System.IO.Stream]].GetResult () [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:580
at FFImageLoading.Work.ImageLoaderTask+<GetStreamAsync>c__async5.MoveNext () [0x000e4] in <filename unknown>:0
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Sharing violation on path in xamarin
Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the default encoding and buffer size....
Read more >System.IO.IOException: Sharing violation on path thrown ...
Create Xamarin.iOS or Xamarin.Android project · Open a Stream and StreamWriter test.txt · Try to copy the file to another location without closing ......
Read more >Sharing violation while building a Xamarin.Forms.iOS project
This is a previously running project. There is no such directory /Users/shantimohan. What's the meaning of this error and how do I remedy...
Read more >xamarin iOS System.IO.IOException: Sharing violation on path ...
The error is caused when you try to Read or Write a file you just created from a separate stream. Solving this is...
Read more >Android System.IO.IOException: Sharing violation only in ...
Hello,. In my xamarin app i'm using this implementation of the reading/writing dependency service to save some data to an xml file.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @pMaske this has nothing to do with FFImageLoading, the lib is only about images, it has no business with CSV files. I guess you should look into your usage of that file, how you open/close the file streams.
Actually I am getting this error. My app creates a csv file to sdcard. when I attempt to open that csv later file I get following error
[0:] Test run failed: System.IO.IOException: Sharing violation on path /storage/emulated/0/UnitTestLogs/2018_01_23_12-16-52_Android_UnitTest_Results.csv 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) [0x001e4] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/corlib/System.IO/FileStream.cs:247 at System.IO.FileStream…ctor (System.String path, System.IO.FileMode mode) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/corlib/System.IO/FileStream.cs:81 at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode)