ArgumentException When trying to ES3.CacheFile

Discussion and help for Easy Save 3
Post Reply
likudo
Posts: 6
Joined: Sat Mar 07, 2020 5:46 pm

ArgumentException When trying to ES3.CacheFile

Post by likudo »

Code: Select all

	//this one has no problem at all, prints nice clean json string
	try
        {
            print(ES3.LoadRawString("0.sav"));
        }
        catch (System.Exception)
        {
            throw;
        }

	//this one makes error
        try
        {
            ES3.CacheFile("0.sav");
        }
        catch (System.Exception)
        {
            throw;
        }

Code: Select all

ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
ES3Internal.ES3Stream.CreateStream (System.IO.Stream stream, ES3Settings settings, ES3Internal.ES3FileMode fileMode) (at Assets/Plugins/Easy Save 3/Scripts/Streams/ES3Stream.cs:117)
ES3Reader.Create (System.Byte[] bytes, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:366)
ES3File.SaveRaw (System.Byte[] bytes, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3File.cs:170)
ES3File..ctor (System.Byte[] bytes, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3File.cs:83)
ES3File.CacheFile (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3File.cs:371)
ES3.CacheFile (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:1464)
ES3.CacheFile (System.String filePath) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:1449)
r35_MapBrain.Start () (at Assets/Scripts/r35_MapBrain.cs:156)
I found that when ES3Stream.cs trying to create a stream in ES3Internal.ES3FileStream there's nothing wrong
but when a stream comes in System.IO.MemoryStream it fire errors.
Am I using the wrong approach to making a cache?

and this is my another action for preventing the Sharing Violation issue, by the way.
(https://moodkie.com/forum/viewtopic.php?p=7494)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentException When trying to ES3.CacheFile

Post by Joel »

Hi there,

I don't appear to be able to replicate this at my end, and I've had no other reports of this. Please could you create a new project with a very basic scene which replicates this and private message it to me?

The only thing I can think is happening is that the data is encrypted, but you've not got encryption enabled when you're calling ES3.CacheFile. If this is the case then you would need to provide an ES3Settings object as a parameter with encryption enabled.

Also just to clarify, you shouldn't directly use the ES3Stream class as this is internal and is likely to cause issues. We only recommend using documented classes.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
likudo
Posts: 6
Joined: Sat Mar 07, 2020 5:46 pm

Re: ArgumentException When trying to ES3.CacheFile

Post by likudo »

Hey Joel,
Thanks for the really quick fix,
but I found out there's a one more issue

ES3.DeleteKey doesn't work as it should in the Cache environment,
so please take a look at this!
I sent a private msg with the sample project as usual.

Many thanks,
r35

-- Edit --
Sorry please forget about this,
shame on me, I actually did miss to set the parameter correctly :oops:
-- Edit2 --
I managed to reproduce the issue on the sample project and resent the msg!
Post Reply