Blecki / dwarfcorp

An open-source 3D colony management game for PC, Mac and Linux
http://www.dwarfcorp.com
Other
580 stars 71 forks source link

Invalid operation exception while serializing save file. [Very common] #1000

Open mklingen opened 5 years ago

mklingen commented 5 years ago

https://sentry.io/cfg/dwarfcorp/issues/868940073/?referrer=github_plugin

TargetInvocationException: Exception has been thrown by the target of an invocation.
  Module "Newtonsoft.Json.Serialization.JsonContract+<>c__DisplayClass73_0", line 0, in CreateSerializationCallback { <lambda> }
    Void <CreateSerializationCallback>b__0(System.Object, System.Runtime.Serialization.StreamingContext)
  Module "Newtonsoft.Json.Serialization.JsonContract", line 22, in InvokeOnSerializing
    Void InvokeOnSerializing(System.Object, System.Runtime.Serialization.StreamingContext)
  Module "Newtonsoft.Json.Serialization.JsonSerializerInternalWriter", line 68, in OnSerializing
    Void OnSerializing(Newtonsoft.Json.JsonWriter, Newtonsoft.Json.Serialization.JsonContract, System.Object)
  Module "Newtonsoft.Json.Serialization.JsonSerializerInternalWriter", line 0, in SerializeObject
    Void SerializeObject(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.Serialization.JsonObjectContract, Newtonsoft.Json.Serialization.JsonProperty, Newtonsoft.Json.Serialization.JsonContainerContract, Newtonsoft.Json.Serialization.JsonProperty)
  Module "Newtonsoft.Json.Serialization.JsonSerializerInternalWriter", line 176, in SerializeValue
    Void SerializeValue(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.Serialization.JsonContract, Newtonsoft.Json.Serialization.JsonProperty, Newtonsoft.Json.Serialization.JsonContainerContract, Newtonsoft.Json.Serialization.JsonProperty)
...
(12 additional frame(s) were not displayed)

InvalidOperationException: Operation is not valid due to the current state of the object.
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\Scripting\Player\GameMaster.cs", line 54, in OnSerializingMethod
    Void OnSerializingMethod(System.Runtime.Serialization.StreamingContext)

Exception has been thrown by the target of an invocation.
mklingen commented 5 years ago

This particular stack trace was caused by @Blecki testing something. However there are other stack traces for more common issues. It seems to be a generic crash for literally anything that happens during serialization.

mklingen commented 5 years ago

Stack traces usually look like this

Newtonsoft.Json.Serialization.JsonContract+<>c__DisplayClass73_0 in CreateSerializationCallback { <lambda> }
Void <CreateSerializationCallback>b__0(System.Object, System.Runtime.Serialization.StreamingContext)
Newtonsoft.Json.Serialization.JsonContract in InvokeOnSerializing at line 22:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in OnSerializing at line 68:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in SerializeObject
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in SerializeValue at line 176:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in SerializeList at line 214:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in SerializeValue at line 212:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in SerializeObject at line 140:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in SerializeValue at line 176:0
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter in Serialize at line 121:0
Newtonsoft.Json.JsonSerializer in SerializeInternal at line 595:0
DwarfCorp.FileUtils in Save at line 170:21
DwarfCorp.SaveGame in WriteFile at line 55:38
DwarfCorp.WorldManager in SaveThreadRoutine at line 764:17
mklingen commented 5 years ago

It's worth noting this only happened in 19.02.02 so it's possible we fixed it accidentally.

Blecki commented 5 years ago

Not my stack trace. It'd have my windows user id in it if it was.