Unity is having an issue selecting the right object for deserialization.
I have successfully serialized to a file and then deserialized from that file in binary format.
But when I try to deserialize from a URL, I’m getting a deserialization error.
The attached project includes a Unity project and a Mono project.
Both versions attempt to deserialize a Mono binary serialized file and a Unity serialized file.
With the same code, MonoDevelop is able to execute the Mono project and get the expected result.
Unfortunately, the Unity editor is getting a deserialization error.
You will find the MonoProject solution in Deserialization002/MonoProject
The expected output running from Mono should be:
From File: Deserialized okay
From Unity Url: Failed to deserialize
From Mono Url: Deserialized okay
The expected output running from the Unity editor should be:
From File: Deserialized okay
From Unity Url: Deserialized okay
From Mono Url: Failed to deserialize
The expected output running from the Unity player should be:
From File: Failed to deserialize
From Unity Url: Deserialized okay
From Mono Url: Failed to deserialize
This is the Unity serialized url:
http://tagenigma.com/qa/Unity3d/WIP/Maps/TF_CityMap_Unity.txt
This is the Mono serialized url:
http://tagenigma.com/qa/Unity3d/WIP/Maps/TF_CityMap_Mono.txt
Here are the rrror details:
System.IO.FileNotFoundException: Could not load file or assembly '8b8fe8916a42f423e841d8c0e08ffe85' or one of its dependencies. The system cannot find the file specified.
File name: '8b8fe8916a42f423e841d8c0e08ffe85'
at <0x00000> <unknown method>
at (wrapper managed-to-native) System.AppDomain:LoadAssembly (string,System.Security.Policy.Evidence,bool)
at System.AppDomain.Load (System.String assemblyString) [0x00000]
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetDeserializationType (Int64 assemblyId, System.String className) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadType (System.IO.BinaryReader reader, TypeTag code) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadTypeMetadata (System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean hasTypeInfo) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectInstance (System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean hasTypeInfo, System.Int64 objectId, System.Object value, System.Runtime.Serialization.SerializationInfo info) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64 objectId, System.Object value, System.Runtime.Serialization.SerializationInfo info) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64 objectId, System.Object value, System.Runtime.Serialization.SerializationInfo info) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (System.IO.BinaryReader reader, Boolean readHeaders, System.Object result, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000]
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000]
at SerializeCache.DeserializeUrl (System.String url, System.Type type) [0x0002a] in /Users/user/Unity/Deserialization002/Assets/SerializeCache.cs:138
UnityEngine.Debug:LogError(Object)