InvalidOperationException problem...

Discussion and help for Easy Save 3
Post Reply
Ubai
Posts: 3
Joined: Fri Aug 18, 2023 10:52 pm

InvalidOperationException problem...

Post by Ubai »

Hello,

I'm getting the following error when I try to run my LoadGalaxy method:

InvalidOperationException: Trying to load data of type Galaxy, but data contained in file is type of System.Collections.Generic.Dictionary`2[UnityEngine.Vector2Int,GalaxyObject].

My Galaxy class contains a dictionary, but it also contains other member variables, so I am not sure why I am getting this error. Can dictionaries not be saved if they are part of a custom class?

Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException problem...

Post by Joel »

Hi there,

I would first try deleting your existing save data by going to Tools > Easy Save 3 > Clear Persistent Data Path in case you've previously saved a Dictionary to the same key.

Also if you've previously created any ES3Types from the Types window, I recommend deleting these and regenerating them. You can delete them from Assets/Easy Save 3/Types/.

If this doesn't resolve the issue please could you show me the scripts you're using to save and load, and also your Galaxy class.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Ubai
Posts: 3
Joined: Fri Aug 18, 2023 10:52 pm

Re: InvalidOperationException problem...

Post by Ubai »

Thanks! I will give that a try and get back to you. :)
Ubai
Posts: 3
Joined: Fri Aug 18, 2023 10:52 pm

Re: InvalidOperationException problem...

Post by Ubai »

Hello again,

I figured it out! First off I was saving the dictionary and not the field. After I fixed that I found out I needed a parameter free constructor before ES3 could handle loading and saving it. I fixed that and created a type and now it works perfectly (so far).

Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: InvalidOperationException problem...

Post by Joel »

Hi there,

If it's saying that you need a parameterless constructor then you're on an older version of Easy Save, so I recommend updating also.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply