Invalid generic arguments exceptions upon updating to Unity 2017.1 from the latest Unity 5
I have been trying in vain to figure out what causes this issue. Upon upgrading my project to 2017.1 (with a backup of course) and inspecting some prefabs many instances of the below error popped out. Sometimes continuously. Generally, these errors appear when inspector fields are being drawn.
Unfortunately, all nullable fields of prefabs/GameObjects serialized with Odin were set to null upon opening the project in Unity 2017. After refilling the null fields with a new object they would eventually get reset to null after poking around in other areas of the inspector and receiving some reports of the below error.
I cannot reproduce this in a clean project.
Unity Version: 2017.1.0f3
The traceback shown for every instance of the error is:
ArgumentException: Invalid generic arguments
Parameter name: typeArguments
System.RuntimeType.MakeGenericType (System.Type[] instantiation) (at /Users/builduser/buildslave/mono/build/mcs/class/referencesource/mscorlib/system/rttype.cs:4272)
Sirenix.Serialization.Serializer.Create (System.Type type) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/Serializer.cs:133)
Sirenix.Serialization.Serializer.Get (System.Type type) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/Serializer.cs:94)
Sirenix.Serialization.Emitted.StartupFormatterHelper..cctor () (at <244b182f5eb64a35b2a827886c70d946>:0)
Rethrow as TypeInitializationException: The type initializer for 'Sirenix.Serialization.Emitted.StartupFormatterHelper' threw an exception.
<0x00000 + 0x00000> <unknown method>
(wrapper dynamic-method) System.Object:Dynamic_Write_Startup (Startup&,Sirenix.Serialization.IDataWriter)
Sirenix.Serialization.FormatterEmitter+EmittedFormatter1[T].WriteDataEntries (T& value, Sirenix.Serialization.IDataWriter writer) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/FormatterEmitter.cs:63)
Sirenix.Serialization.EasyBaseFormatter
1[T].SerializeImplementation (T& value, Sirenix.Serialization.IDataWriter writer) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/EasyBaseFormatter.cs:47)
Sirenix.Serialization.BaseFormatter1[T].Serialize (T value, Sirenix.Serialization.IDataWriter writer) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/BaseFormatter.cs:244)
UnityEngine.Debug:LogException(Exception)
Sirenix.Serialization.CustomLogger:LogException(Exception) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization.Config/CustomLogger.cs:61)
Sirenix.Serialization.DebugContext:LogException(Exception) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Misc/SerializationConfig.cs:222)
Sirenix.Serialization.BaseFormatter
1:Serialize(Startup, IDataWriter) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/BaseFormatter.cs:248)
Sirenix.Serialization.BaseFormatter1:Sirenix.Serialization.IFormatter.Serialize(Object, IDataWriter) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/BaseFormatter.cs:113)
Sirenix.Serialization.ComplexTypeSerializer
1:WriteValue(String, Startup, IDataWriter) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/ComplexTypeSerializer.cs:492)
Sirenix.Serialization.Serializer`1:WriteValueWeak(String, Object, IDataWriter) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/Serializer.cs:187)
Sirenix.Serialization.UnitySerializationUtility:SerializeUnityObject(Object, IDataWriter, Boolean) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Utilities/UnitySerializationUtility.cs:717)
Sirenix.Serialization.UnitySerializationUtility:SerializeUnityObject(Object, SerializationData&, Boolean, SerializationContext) (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Utilities/UnitySerializationUtility.cs:420)
Sirenix.OdinInspector.SerializedMonoBehaviour:UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize() (at C:/Users/Bjarke/Desktop/Projects/Sirenix/Sirenix Solution/Sirenix.Serialization/Unity Integration/SerializedMonoBehaviour.cs:32)
Comments (8)
-
-
Changing the runtime version back to 3.5 and reopening the project retains all serialized information as if I never switched to 4.6 in the first place.
-
With the version set to 4.6:
Reimporting all assets causes Unity to crash and subsequently crash each time the same project is opened afterward.
-
The crash is a known bug that's caused by Unity itself when it imports assemblies. We've communicated with Unity and supposedly they're going to patch it very soon.
The other bug is a new one - we'll give that a prompt look. Thanks for reporting it! The new 4.6 scripting backend is proving to be quite temperamental.
-
- changed status to open
-
- changed status to resolved
I've identified and fixed the other issue with the exceptions you're getting - it seems that some generic class constraints function differently in .NET 4.6. This happens when Odin is preparing to serialize or deserialize an enum value (or something containing an enum), and throws exceptions in a rather unexpected part of the system, thus causing a lot of lost values.
-
If getting a fix for this is a very high priority for you, you can send me a mail at tor@sirenix.net with your invoice number, and I'll send you a build containing the fix.
-
I'm not in much of a rush. Mostly just looking forward to auto property initializers. Best of luck with the next patch!
- Log in to comment
Same person as above.
Found out this only happens after changing the Scripting Runtime Version to 4.6 AFTER opening the project in Unity 2017.1. Everything seems to be fine before changing that.