Page 1 of 1

Null reference error in Merge()

Posted: Thu Jul 22, 2021 9:34 pm
by GiftedMamba
Hi. I have a weird behaviuor in my android game.
In the previous game version saving system works fine.
In my new version it works fine too if I do a clean installation.
But if I install on top of previous version, saving system stops working completely.

Error is "NullReferenceException in ES3Writer.Merge(Reader reader)"

I double checked all my values, keys and filenames which I pass to the saving system. They are not null

I started to check each key-value pair in

Code: Select all

reader.RawEnumerator
and I detected that in my previous version I had enum Period_Type, but in current version I removed this enum, but Easy Save is somehow trying to use it when it performs

Code: Select all

ES3Writer.Merge(Reader reader)
And when it is trying to access field "type" of Period_Type, NullReference error occurs.

For now I have added try-catch block and saving system starts working. Could you recommend how to manage this situation in a proper way? Why is ES3Writer still trying to access Period_Type enum and how should I clean it?

Re: Null reference error in Merge()

Posted: Thu Jul 22, 2021 9:59 pm
by Joel
Hi there,

This error will be because your save data contains data of this type, which you are asking it to load. In this case you would either need to remove the data from your file (i.e. using ES3.DeleteKey), or use a try/catch block as you are doing.

All the best,
Joel

Re: Null reference error in Merge()

Posted: Thu Jul 22, 2021 10:07 pm
by GiftedMamba
Thank you for your quick response.

So as I understand from your answer, if I delete any type in my game which I previously saved with ES3, I should manualy delete all keys of this type in game saves?

Re: Null reference error in Merge()

Posted: Fri Jul 23, 2021 7:15 am
by Joel
Correct, if you wish to load it. It would be impossible to load the data if the type doesn't exist.

All the best,
Joel