IOException: Sharing violation

Discussion and help for Easy Save 3
Post Reply
Rdbk
Posts: 35
Joined: Sun Jun 09, 2019 3:58 pm

IOException: Sharing violation

Post by Rdbk »

Hey, I recently released my game and I have now gotten several reports of the game getting stuck (not full freeze or crash, but unable to proceed). After going through some logs, I located the issue to an error with saving:

Code: Select all

IOException: Sharing violation on path C:\Users\bill\AppData\LocalLow\Redbeak Games\MortalGlory\Data.es3
  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) [0x001b7] in <a6266edc72ee4a578659208aefcdd5e1>: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.IO.FileOptions options) [0x00000] in <a6266edc72ee4a578659208aefcdd5e1>: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 useAsync) [0x00000] in <a6266edc72ee4a578659208aefcdd5e1>:0 
  at ES3Internal.ES3FileStream..ctor (System.String path, ES3Internal.ES3FileMode fileMode, System.Int32 bufferSize, System.Boolean useAsync) [0x00014] in <af4b67ed62634f8c958790e4f913802b>:0 
  at (wrapper remoting-invoke-with-check) ES3Internal.ES3FileStream..ctor(string,ES3Internal.ES3FileMode,int,bool)
  at ES3Internal.ES3Stream.CreateStream (ES3Settings settings, ES3Internal.ES3FileMode fileMode) [0x00046] in <af4b67ed62634f8c958790e4f913802b>:0 
  at ES3Reader.Create (ES3Settings settings) [0x00000] in <af4b67ed62634f8c958790e4f913802b>:0 
  at ES3Writer.Merge () [0x00000] in <af4b67ed62634f8c958790e4f913802b>:0 
  at ES3Writer.Save (System.Boolean overwriteKeys) [0x00003] in <af4b67ed62634f8c958790e4f913802b>:0 
  at ES3Writer.Save () [0x00000] in <af4b67ed62634f8c958790e4f913802b>:0 
  at ES3.Save[T] (System.String key, System.Object value) [0x00013] in <af4b67ed62634f8c958790e4f913802b>:0 
  at SaveManager.Save (System.Boolean FullSave) [0x003a8] in <2b4b6e2fed764e8b91d257ed3203e660>:0 
  at TownManager.Start () [0x00256] in <2b4b6e2fed764e8b91d257ed3203e660>:0 
Any idea what causes this? This happens quite rarely, but too often as multiple people have reported it.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: IOException: Sharing violation

Post by Joel »

Hi there,

This occurs when the save file is being accessed by another program or process. For example, the user has the file open in a text editor, or cloud software is trying to sync the file to the cloud but hasn't locked the file.

Unfortunately there's no way to prevent other software from accessing the file, so it's usually best just to catch the exception and display an error message to the user.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Rdbk
Posts: 35
Joined: Sun Jun 09, 2019 3:58 pm

Re: IOException: Sharing violation

Post by Rdbk »

Hey Joel,

Thanks for the tip! Added error catching to the method.
Post Reply