Glue: Send/Receive Unity data buffer serialized with Ceras

  • CerasUnityIssues.Unity/ Simple Unity HDRP scene using our plugin to receive data from GlueSender application
  • de.nsynk.unity.glue/ Our Unity plugin to receive Ceras serialized data via UDP socket
  • GlueSender/ Simple C# program to send buffers from files over a socket

Get Up and Running

  1. Open CerasUnityIssues.Unity with Unity
  2. Open GlueSender/GlueSender.sln and compile the application
    • GlueSender is reading a binary file that was serialized with Ceras directly from our projects
    • It will be send over UDP socket and received by Unity
  3. In Unity start the "Play Mode". Using Menu/NSYNK/GlueInspector you should be able to see the values that were send over the socket.
  4. From time to time (couldn't really understand WHEN that is happening), Unity will catch an Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: An item with the same key has already been added. Key: System.Object at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000c1] in <7d97106330684add86d080ecf65bfe69>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <7d97106330684add86d080ecf65bfe69>:0 at Ceras.SerializerConfig.GetTypeConfig (System.Type type, System.Boolean isStatic) [0x00076] in :0 at Ceras.CerasSerializer.CreateMetaData (System.Type type, System.Boolean isStatic) [0x00040] in :0 at Ceras.CerasSerializer.GetTypeMetaData (System.Type type) [0x00014] in :0 at Ceras.CerasSerializer.GetReferenceFormatter (System.Type type) [0x00000] in :0 at Ceras.CerasSerializer.PrepareFormatter (Ceras.Formatters.IFormatter formatter) [0x00182] in :0 at Ceras.CerasSerializer.GetSpecificFormatter (System.Type type, Ceras.TypeMetaData meta) [0x00152] in :0 at Ceras.CerasSerializer.GetReferenceFormatter (System.Type type) [0x00015] in :0 at Ceras.Formatters.CollectionFormatter2[TCollection,TItem]..ctor (Ceras.CerasSerializer serializer) [0x00011] in <b6da9313954f478babe228ea7d57b8e3>:0 at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <7d97106330684add86d080ecf65bfe69>:0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <7d97106330684add86d080ecf65bfe69>:0 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <7d97106330684add86d080ecf65bfe69>:0 at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <7d97106330684add86d080ecf65bfe69>:0 at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <7d97106330684add86d080ecf65bfe69>:0 at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000a1] in <7d97106330684add86d080ecf65bfe69>:0 at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <7d97106330684add86d080ecf65bfe69>:0 at Ceras.Resolvers.CollectionFormatterResolver.GetFormatter (System.Type type) [0x0024b] in <b6da9313954f478babe228ea7d57b8e3>:0 at Ceras.CerasSerializer.GetSpecificFormatter (System.Type type, Ceras.TypeMetaData meta) [0x0013e] in <b6da9313954f478babe228ea7d57b8e3>:0 at Ceras.CerasSerializer.GetSpecificFormatter (System.Type type) [0x00008] in <b6da9313954f478babe228ea7d57b8e3>:0 at Ceras.Formatters.ReferenceFormatter1[T].GetOrCreateEntry (System.Type type) [0x00041] in :0 at Ceras.Formatters.ReferenceFormatter1[T].Deserialize (System.Byte[] buffer, System.Int32& offset, T& value) [0x000d3] in <b6da9313954f478babe228ea7d57b8e3>:0 at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,byte[],int&,Glue.Frame&) at Ceras.Formatters.DynamicFormatter1[T].Deserialize (System.Byte[] buffer, System.Int32& offset, T& value) [0x00000] in :0 at Ceras.Formatters.ReferenceFormatter`1[T].Deserialize (System.Byte[] buffer, System.Int32& offset, T& value) [0x0018c] in :0 at Ceras.CerasSerializer.DeserializeT [0x00076] in :0 at Ceras.CerasSerializer.DeserializeT [0x00002] in :0 at Glue.GlueConnector.ReceiveFrame (System.IAsyncResult result) [0x0004d] in D:_UnityDev\VW-IAA19-UnityHDRP\Library\PackageCache\de.nsynk.unity.glue@d223905ed04c946e895f1f1df547b0f19eb6e300\GlueConnector.cs:120 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object) UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:Log(Object) Glue.GlueConnector:ReceiveFrame(IAsyncResult) (at Library\PackageCache\de.nsynk.unity.glue@d223905ed04c946e895f1f1df547b0f19eb6e300\GlueConnector.cs:135) System.Net.Sockets.<>c:b__27_0(Object) System.Threading.QueueUserWorkItemCallback:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() System.Threading.ThreadPoolWorkQueue:Dispatch() System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()

(Filename: Library/PackageCache/de.nsynk.unity.glue@d223905ed04c946e895f1f1df547b0f19eb6e300/GlueConnector.cs Line: 135)