Throwing exception:::System.InvalidOperationException error

Discussion and help for Easy Save 3
Post Reply
hamh
Posts: 6
Joined: Mon Dec 26, 2022 12:39 pm

Throwing exception:::System.InvalidOperationException error

Post by hamh »

I used serializer before and now I am using this.
But i can't solve the problem with this.

Throwing exception:::System.InvalidOperationException: Trying to load data of type company, but data contained in file is type of System.String.

'company' is a serialized class. I didn't register it as a type in es3, and it worked well, so I used it as is.

But all of a sudden it's spitting out this error.
Nothing special has changed. But this problem happened.
how do i solve it?
hamh
Posts: 6
Joined: Mon Dec 26, 2022 12:39 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by hamh »

When I open the json, I see this.
And in the try statement during loading, it is executed and then throws an exception.


"__type" : "company,Assembly-CSharp",
"value" : {
"a1" : null,
"a2" : [
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by Joel »

Hi there,

Unfortunately it's not possible to tell what is happening from what you've sent. Please could you show me the code you are using to load, and the complete save file (rather than just a portion of it).

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hamh
Posts: 6
Joined: Mon Dec 26, 2022 12:39 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by hamh »

Once I removed easysave and reattached it, it works :)
But another problem occurred :(

System.FormatException: Expected ',' separating properties or '"' before property name, found '{'.

this is it
I'm doing the save async.
Occasionally there may be omissions, but it doesn't matter if this data is slightly corrupted.
Save doesn't work because of this exception.
How can I force a save?

System.FormatException: Expected ',' separating properties or '"' before property name, found '{'.
at ES3Internal.ES3JSONReader.ReadPropertyName () [0x0007e] in F:\UnityInPub\cap_final - VerUpgrade\Assets\Plugins\Easy Save 3\Scripts\Readers\ES3JSONReader.cs:74
at ES3Internal.ES3JSONReader.ReadKeyPrefix (System.Boolean ignoreType) [0x00009] in F:\UnityInPub\cap_final - VerUpgrade\Assets\Plugins\Easy Save 3\Scripts\Readers\ES3JSONReader.cs:88
at ES3Reader.ReadTypeFromHeader[T] () [0x0009e] in F:\UnityInPub\cap_final - VerUpgrade\Assets\Plugins\Easy Save 3\Scripts\Readers\ES3Reader.cs:316
at ES3Reader.Read[T] (System.String key, T defaultValue) [0x0000b] in F:\UnityInPub\cap_final - VerUpgrade\Assets\Plugins\Easy Save 3\Scripts\Readers\ES3Reader.cs:215
at ES3.Load[T] (System.String key, T defaultValue, ES3Settings settings) [0x00025] in F:\UnityInPub\cap_final - VerUpgrade\Assets\Plugins\Easy Save 3\Scripts\ES3.cs:491
at ES3.Load[T] (System.String key, T defaultValue) [0x00000] in F:\UnityInPub\cap_final - VerUpgrade\Assets\Plugins\Easy Save 3\Scripts\ES3.cs:453
at TotalProfit.Ez_Load () [0x00084] in F:\UnityInPub\cap_final -
hamh
Posts: 6
Joined: Mon Dec 26, 2022 12:39 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by hamh »

Ah, this is the result of removing the try catch statement and executing it.


FormatException: Expected ',' separating properties or '"' before property name, found '{'.
ES3Internal.ES3JSONReader.ReadPropertyName () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:74)
ES3Internal.ES3JSONReader.ReadKeyPrefix (System.Boolean ignoreType) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:88)
ES3Reader.ReadTypeFromHeader[T] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:306)
ES3Reader+ES3ReaderRawEnumerator+<GetEnumerator>d__2.MoveNext () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:444)
ES3Writer.Merge (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:471)
ES3Writer.Merge () (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:461)
ES3Writer.Save (System.Boolean overwriteKeys) (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:487)
ES3Writer.Save () (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:479)
ES3.Save[T] (System.String key, T value, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:111)
ES3.Save[T] (System.String key, T value) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:71)
AsyncSave.Box2 () (at Assets/3_Script/Save/AsyncSave.cs:155)
UnityEngine.Events.InvokableCall.Invoke () (at <4746c126b0b54f3b834845974d1a9190>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <4746c126b0b54f3b834845974d1a9190>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by Joel »

Hi there,

I first recommend deleting your save data and seeing if the error still occurs. If so, please could you replicate your issue in a new project with a simple scene and private message it to me so I can see what is happening.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hamh
Posts: 6
Joined: Mon Dec 26, 2022 12:39 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by hamh »

Unfortunately, since it is a game that has already been published,
I have to restore save this data (there is no way to do it because it did not exist until now) :(
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by Joel »

Hi there,

In that case please could you create a new project with a simple scene which tries to load the data from your save file and private message it to me with instructions, along with the save file itself.

The mostly likely cause is that you’ve changed the type of a field in the data you’ve saved, so now the save data is no longer valid for the type you’re loading.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hamh
Posts: 6
Joined: Mon Dec 26, 2022 12:39 pm

Re: Throwing exception:::System.InvalidOperationException error

Post by hamh »

hello,

I seem to have found the problem.
The problem seems to be the part where something written with stringbuilder is converted to tostring() and then stored in a string[,] array.
First problem after removing it, running the type check worked fine.
I'll test some more and let you know.

thank you
Post Reply