Null reference error in Merge()

Discussion and help for Easy Save 3
Post Reply
GiftedMamba
Posts: 2
Joined: Thu Jul 22, 2021 8:30 pm

Null reference error in Merge()

Post 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?
Last edited by GiftedMamba on Thu Jul 22, 2021 10:00 pm, edited 1 time in total.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Null reference error in Merge()

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
GiftedMamba
Posts: 2
Joined: Thu Jul 22, 2021 8:30 pm

Re: Null reference error in Merge()

Post 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?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Null reference error in Merge()

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply